包含
包含讓你可以將一個 Pug 檔案的內容插入到另一個檔案中。
如果路徑是絕對路徑(例如,include /root.pug
),則會透過在前面加上 options.basedir
來解析。否則,路徑會根據目前正在編譯的檔案來解析。
如果沒有提供檔案副檔名,則會自動在檔案名稱後面加上 .pug
。
包含純文字
包含非 Pug 檔案僅會包含其原始文字。
包含經過篩選的文字
您可以將篩選器與包含合併,讓您在包含時篩選內容。
//- index.pug
html
head
title An Article
body
include:markdown-it article.md
# article.md
This is an article written in markdown.
<html>
<head>
<title>An Article</title>
</head>
<body>
<h1>article.md</h1>
<p>This is an article written in markdown.</p>
</body>
</html>