pug
index.pug
pug
//- index.pug
doctype html
html
include includes/head.pug
body
h1 我的网站
p 欢迎来到我这简陋得不能再简陋的网站。
include includes/foot.pug
被包含的文件的路径,如果是一个绝对路径(如 include /root.pug
),那么前面会加上 options.basedir
选项属性来进行解析。否则,路径应该相对于正在被编译的当前文件。
在 Pug v1 里,如果没有给出文件扩展名,会自动加上 .pug
。但是这个特性在 Pug v2 中这是不赞成使用的。
包含纯文本 Including Plain Text
被包含的如果不是 Pug 文件,那么就只会当作文本内容来引入。
pug
index.pug
pug
//- index.pug
doctype html
html
head
style
include style.css
body
h1 我的网站
p 欢迎来到我这简陋得不能再简陋的网站。
script
include script.js
使用过滤器包含文本 Including Filtered Text
您可以合并过滤器和包含语句,从而做到引入文件内容并直接用过滤器处理它们。
pug
index.pug
pug
//- index.pug
doctype html
html
head
title 一篇文章
body
include:markdown-it article.md