I have 3 files: layoutA.jade, layoutB.jade and index.jade. How can I programmatically set which layout that index.jade will extend?
I’ve tried using:
app.set('view options', { layout: false });
with:
res.render('index', { title: 'Express', layout: 'layoutB' }); // older 2.x way?
I can’t seem to override anything set explicitly in the index.jade file. Omitting the extends line inside the index.jade file didn’t work either.
Lets say the jade files are in the following directory:
Add the layout settings in the correct order, and specify the root views folder:
Make sure you specify the correct folder(in this case ‘views’). Also make sure to specify a valid default layout. Check that this works with a test page before you dive deeper.
Once that is working you can the default layout like this: