如何使用不同文件中的多个块?

Amb*_*mps 7 templates node.js express pug

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

html
  body
    block content
    block footer
Run Code Online (Sandbox Code Playgroud)

content.jade看起来像那样:

extends layout

block content
    #Content Welcome
Run Code Online (Sandbox Code Playgroud)

footer.jade看起来像那样:

extends layout

block footer
    #Footer Impressum
Run Code Online (Sandbox Code Playgroud)

现在,当我app这样做的时候:

app.get('/', function(req, res) {
    res.render('layout');
});
Run Code Online (Sandbox Code Playgroud)

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

当我跑:

app.get('/', function(req, res) {
    res.render('content');
});
Run Code Online (Sandbox Code Playgroud)

然后我看到了内容.

当我跑:

app.get('/', function(req, res) {
    res.render('footer');
});
Run Code Online (Sandbox Code Playgroud)

然后我看到页脚.

我怎样才能看到内容和页脚?

Mic*_*ley 21

你可能想要这样的东西:

layout.jade

html
  body
    block content
    include footer
Run Code Online (Sandbox Code Playgroud)

pagename.jade

extends layout

block content
  h1 My Content
Run Code Online (Sandbox Code Playgroud)

footer.jade

p.footer Here is my footer
Run Code Online (Sandbox Code Playgroud)

然后跑res.render('pagename');.

除非你想在每页的页脚中包含特定的内容,否则将其作为一个块是没有意义的.