【问题标题】:Multiple extend blocks多个扩展块
【发布时间】:2014-07-03 02:16:06
【问题描述】:

所以我使用jade构建了几个网页,但是我的登录页面在其他页面中的不同之处在于它没有菜单。除了它共享相同的页眉和页脚。我的问题是我想有条件地将 menu.jade 包含在转换为 html 中。我想做这样的事情:

base.jade:

doctype html
  head
    title= title
  body
    block menu
    block content
    include footer

menu.jade

extends base
  ul
    li Home
    li Contact

index.jade:

extends base
block content
  p hello landingpage

page.jade

extends base
block content
  p hello subpage

问题是:当我转换 index.jade 时,一切都很好;我的页面看起来像我想要的那样。但是当我转换 page.jade 时,我不知何故也想包含 menu.jade,o 我不必在所有子页面中重写我的菜单。

【问题讨论】:

    标签: node.js pug template-engine


    【解决方案1】:

    menu.jade

    ul
       li Home
       li Contact
    

    page.jade

    extends base
    block menu
       include menu
    block content
       p hello subpage
    

    anotherpage.jade

    extends page
    block content
       p hello another page
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-15
      • 1970-01-01
      • 2021-05-04
      • 2023-01-15
      相关资源
      最近更新 更多