Express 翡翠/特快积木未出现

Express 翡翠/特快积木未出现,express,pug,Express,Pug,我在这个话题上做了很多搜索,但似乎没有找到任何对我有帮助的东西。我试图使用jade的块和扩展功能渲染页眉和页脚,而不是include 这就是我所拥有的,我似乎不明白为什么它不会呈现 layout.jade html head title= title body block header block content footer block footer extends layout block content h1= title p We

我在这个话题上做了很多搜索,但似乎没有找到任何对我有帮助的东西。我试图使用jade的
扩展
功能渲染页眉和页脚,而不是include

这就是我所拥有的,我似乎不明白为什么它不会呈现

layout.jade

html
  head
   title= title

  body
   block header
   block content

   footer
     block footer
extends layout

block content
  h1= title
  p Welcome to #{title}
extends layout 

block header
  h1 this is a header
extends layout

block footer
  h2 this is a footer
index.jade

html
  head
   title= title

  body
   block header
   block content

   footer
     block footer
extends layout

block content
  h1= title
  p Welcome to #{title}
extends layout 

block header
  h1 this is a header
extends layout

block footer
  h2 this is a footer
header.jade

html
  head
   title= title

  body
   block header
   block content

   footer
     block footer
extends layout

block content
  h1= title
  p Welcome to #{title}
extends layout 

block header
  h1 this is a header
extends layout

block footer
  h2 this is a footer
footer.jade

html
  head
   title= title

  body
   block header
   block content

   footer
     block footer
extends layout

block content
  h1= title
  p Welcome to #{title}
extends layout 

block header
  h1 this is a header
extends layout

block footer
  h2 this is a footer

任何帮助都将不胜感激。

我认为您误解了“扩展模板”的含义。扩展
layout.jade
的每个模板都应编译成自己的页面。也就是说,
layout
为每个扩展页面的外观定义了蓝图。这里的继承模式不是双向的:当看到
布局
模板有一个
页脚
块时,帕格不会搜索所有其他模板以寻找可能的块实现。相反,您告诉它编译子模板,如
索引
模板

对于您的情况,我建议如下:要么将页脚和页眉内容直接包含在
layout.jade
中,要么
include
中,而不使用
block
语句


务必保持
索引
模板的原样-IMHO,这是模板继承的正确使用模式。

我来自laravel,模板引擎在那里使用该功能。这就是困惑的根源。感谢您的解释,我正试图摆脱使用include功能。