I don't want it to be layout.ejs.
I want to se开发者_运维百科t my layout to be another template for THIS specific controller.
Try using:
app.set("view options", { layout: "mylayout.jade" });
Use the layout
option to res.render()
res.render('page', { layout: 'mylayout.jade' })
Set custom default layout
Just set layout property in express app settings.
app.set('layout', 'layouts/layout');
Set custom layout for single render
Just pass layout as render locals object.
app.get('/', function(req, res) {
res.render('the-view', { layout: 'specific-layout' });
);
More info here: https://www.npmjs.com/package/express-ejs-layouts
Providing you're using the Ejs-express-layouts module you can specify a layout for a particular view, overriding the default:
app.get('/', function(req, res){
res.render('aView', { layout: 'someSpecificLayout' })
})
精彩评论