开发者

Multiple Layout files in node.js express framework

开发者 https://www.devze.com 2023-03-30 23:54 出处:网络
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

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: 'my开发者_StackOverflow社区layout'
});


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, e.g. layout.jade

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号