Closed ralyodio closed 11 years ago
You can do this in login.ejs:
<% block('title', "Login page") %>
And in layout.ejs:
<title><%= blocks.title %></title>
Is there any advantage over just doing:
<% title = 'Login page' %> in the login.ejs
and then <%= title %> in the layout.ejs
It seems to work this way, but as soon as I introduced var, it broke everything.
Honestly I don't know, I'm surprised that works at all. I think that it's creating a global variable. With luck the global only exists in the context of the template!
thanks, i'll use the block() just to be safe.
One more issue, can I use a filter with a block?
If you apply the filter when using the block content it should work fine.
Something like <title><%=: blocks.title | capitalize %></title>
should do it. I confess that I didn't test filters when I wrote this stuff but I have tested them since and they seem to work OK.
I can't do it like that -- I only have one place where the title uses a filter.
This is causing page not to be rendered, data is not found:
login.ejs <% layout(layout) %> <% var title = 'Login page' %>
layout.ejs <title><%= title %></title>
It works fine if I remove the 'var' in the partial.