RandomEtc / ejs-locals

Express 3.x layout, partial and block template functions for the EJS template engine.
298 stars 63 forks source link

pass a variable to layout #21

Closed ralyodio closed 11 years ago

ralyodio commented 11 years ago

Is it possible to pass a variable to a layout from withing a page.ejs file?

I am doing this now, but it is a global variable I believe:

item.ejs

<% pg = 'item'; %>
<% layout('../layout') -%>

layout.ejs

    <section class="<%= pg ? pg : '' %>">
RandomEtc commented 11 years ago

There's some discussion of this in #14 - right now you should use blocks to do this. You can also pass the variable in when you call res.render.

Consider just having two layouts and/or using includes for the common parts?