这里不是叠加(类似 _.merge()),而是覆盖(类似 _.extend())
//- layout.jade
doctype html
html
head
block title
title Default Title
body
block content
//- index.jade
extends ./layout/layout.jade
//- 进行替换
block title
title New Title
block content
h1 extends demo
p content
以下是文件navbar.jade
block content
nav.navbar.navbar-default.navbar-fixed-top
.container
.navbar-header
.navbar-brand XJTU HOME
ul.nav.navbar-nav.navbar-right
li
.navbar-btn#btn-excel.btn.btn-default
| Edit Excel
.navbar-btn#btn-account.btn.btn-default
| update account
.navbar-btn#btn-<a href="https://www.jb51.cc/tag/logo/" target="_blank" class="keywords">logo</a>ut.btn.btn-default
| Sign Out
include modals/alert
block scripts
script(src='/js/views/navbar.js')
script(src='/js/controllers/navbarController.js')
home.jade
extends navbar
block content
block scripts
script(src='/vendor/jquery-2.2.3.min.js')
script(src='/vendor/jquery.form.min.js')
script(src='/vendor/bootstrap.min.js')
block content,block scripts 相当于对象中的 属性名称, 出现就会覆盖原有的 navbar中的对应项。
include
其实就是将文件原封不动的导入。
特别注意缩进, 文件里没缩进,外面就要缩进( include xxx)
block content
include navbar
include modals/alert</code></pre>
原文链接:https://www.f2er.com/note/421422.html