我有一个Main.pug
文件,我正在使用它作为我希望包含在其中的多个其他.pug
文件的容器。然而,其他文件集不是静态的,即Main.pug
可能包括A.pug
或它可能包括B.pug
。使用哪个文件将从快递传递类似于以下内容:
app.get('/', function(req, res) {
res.render('main', {section:"A.pug"})
})
我在Main.pug中尝试了几种方法,包括以下内容:
include #{section}
它似乎不起作用。有没有人有关于如何实现这一目标的建议或提示?
试试这个。
app.get('/', function(req, res) {
res.render('main', {section:"A"})
})
在main.pug
内
-if (section == 'A')
include A.pug
-else if(section == 'B')
include B.pug
希望能帮助到你。