gpt4 book ai didi

node.js - 如何使用来自不同文件的多个 block ?

转载 作者:搜寻专家 更新时间:2023-10-31 22:21:32 25 4
gpt4 key购买 nike

我有一个看起来像这样的 layout.jade:

html
body
block content
block footer

我的 content.jade 看起来像这样:

extends layout

block content
#Content Welcome

我的 footer.jade 看起来像这样:

extends layout

block footer
#Footer Impressum

现在,当我像这样运行我的 app 时:

app.get('/', function(req, res) {
res.render('layout');
});

我既没有看到内容也没有看到页脚。

当我运行时:

app.get('/', function(req, res) {
res.render('content');
});

然后我看到了内容。

当我运行时:

app.get('/', function(req, res) {
res.render('footer');
});

然后我看到了页脚。

如何同时查看内容和页脚?

最佳答案

你可能想要这样的东西:

layout.jade

html
body
block content
include footer

pagename.jade

extends layout

block content
h1 My Content

footer.jade

p.footer Here is my footer

然后运行 ​​res.render('pagename');

除非您想在每页的页脚中包含特定的内容,否则将其设为 block 是没有意义的。

关于node.js - 如何使用来自不同文件的多个 block ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12046764/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com