简体   繁体   中英

Multiple Layout files in node.js express framework

I have setup a project in node with the express framework. I like that it allows me to create a layout with a file called "layout" in the views directory. But what if I want to have multiple layout files? I don't see an option for that. Does anyone know a way?

Maybe something like:

res.render('report', {
        title: 'My report',
        layoutfile: 'mylayout'
});

layout is what you're looking for :)

res.render('report', {
       title : 'My report'
    , layout : 'mylayout'
});

Assuming that the file matches the engine you're using. If not, you need to tack on the extension, eg layout.jade

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM