Is there any way to have a template inherit another template? I'm not using Rails.
I also really like the django template inheritance, but it's not available at least with sinatra.
The sinatra book explains how you can use a layout.erb
to define a standard page layout:
You just need to define a views/layout.erb
file with something like:
<html>
<head>..</head>
<body>
<%= yield %>
</body>
</html>
And then call your erb template with erb :index
for example. Sinatra will render both templates and include the contents of your index template inside the result of the layout.erb rendering.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With