Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EJS layouts on Express 3

I am having some problem with the EJS layout file on Express 3. Express just can't seem to find the layout for rendering. It just skips the layout.ejs totally which means that the output misses out of all the stylesheets and such.

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

and the configuration part,

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

and in the layout.ejs I have added the body tag,

<%- body %>

I have been trying out Jade before and it worked just fine, so the problem is just EJS.

Thanks in advance.

like image 217
Andreas Selenwall Avatar asked Oct 29 '12 11:10

Andreas Selenwall


1 Answers

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

I am uncertain whether the above has been updated but it suggests that layout functionality has been deprecated in express 3.

As a result, I have been using ejs-locals to implement equivalent functionality:

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

like image 77
Michael Avatar answered Oct 30 '22 22:10

Michael