包括(Includes)

¥Includes

包含允许你将一个 Pug 文件的内容插入到另一个 Pug 文件中。

¥Includes allow you to insert the contents of one Pug file into another.

如果路径是绝对路径(例如 include /root.pug),则通过在前面添加 options.basedir 来解析。否则,路径将相对于当前正在编译的文件进行解析。

¥If the path is absolute (e.g., include /root.pug), it is resolved by prepending options.basedir. Otherwise, paths are resolved relative to the current file being compiled.

如果未给出文件扩展名,则 .pug 会自动附加到文件名中。

¥If no file extension is given, .pug is automatically appended to the file name.

包括纯文本(Including Plain Text)

¥Including Plain Text

包含非 Pug 文件只需包含其原始文本。

¥Including non-Pug files simply includes their raw text.

包括过滤的文本(Including Filtered Text)

¥Including Filtered Text

你可以将过滤器与包含结合起来,从而允许你在包含内容时对其进行过滤。

¥You can combine filters with includes, allowing you to filter things as you include them.

//- index.pug
doctype html
html
  head
    title An Article
  body
    include:markdown-it article.md
# article.md

This is an article written in markdown.
<!DOCTYPE html>
<html>
  <head>
    <title>An Article</title>
  </head>
  <body>
    <h1>article.md</h1>
    <p>This is an article written in markdown.</p>
  </body>
</html>
Pug 中文网 - 粤ICP备13048890号