EJS Layouts on Express 3

I am having a problem with an EJS layout file in Express 3. Express simply cannot find the layout for rendering. It just skips layout.ejs completely, which means the output skips all stylesheets, etc.

res.render('login', { user: req.user }); 

and configuration parts

 app.set('views', __dirname + '/views'); app.set('view engine', 'ejs'); 

and in layout.ejs I added a body tag,

 <%- body %> 

I tested Jade before and it worked just fine, so the problem is just EJS.

Thanks in advance.

+6
source share
1 answer

https://github.com/visionmedia/ejs/issues/48

I'm not sure if the above has been updated, but this suggests that the layout functionality is deprecated in express 3.

As a result, I used ejs-locals to implement equivalent functions:

https://github.com/RandomEtc/ejs-locals

+11
source

All Articles