如何在Wyam的帖子中包含其他文件?

如何在Wyam的帖子中包含其他文件?,wyam,Wyam,我试图在Wyam帖子中包含一个带有html的文件,但我真的不知道如何让它工作 config.wyam 我在config.wyam中尝试了几种方法 首先将Include模块添加到RenderBlogPosts 博客旁 然后我尝试添加另一条管道 Pipelines.Add("Content", ReadFiles("**/*.md"), Include(), WriteFiles() ); 我想使用它在标记文件test.md中包含一个html文件test-include.

我试图在Wyam帖子中包含一个带有html的文件,但我真的不知道如何让它工作

config.wyam 我在config.wyam中尝试了几种方法

首先将Include模块添加到RenderBlogPosts

博客旁

然后我尝试添加另一条管道

Pipelines.Add("Content",
    ReadFiles("**/*.md"),
    Include(),
    WriteFiles()
); 
我想使用它在标记文件test.md中包含一个html文件test-include.html。这些文件都在同一目录中

test.md 这里我使用了

test-include.html 预期结果 实际结果
我做错了什么?

您使用的是什么版本的Wyam?听起来你也在使用博客食谱,对吗?如果在最新版本上使用配方,则默认情况下启用,因此不需要添加任何额外的模块或管道。这是包含文件的最简单方法旧的包含模块将继续工作,但正如您所注意到的,它需要手动添加

试试这个:

---
Title: Test include
Published: 4/6/2019
Tags: [General]
---

# This page should contain the included content

<?# Include "test-include.html" /?>

如果包含的文件包含标记语法,您甚至可以在标记引擎运行之前包含它,只需稍作语法更改:

---
Title: Test include
Published: 4/6/2019
Tags: [General]
---

# This page should contain the included content

<?! Include "test-include.md" /?>


这就成功了。非常感谢你。文档中是否提到过这一点。我所发现的只是,这并没有提到你上面描述的方式。这会为我节省大量时间。@johanverger短代码是刚刚添加的一项新功能。在中对它们进行了总体描述,在中对每一个都进行了更具体的描述,尽管在食谱中使用它们的解释肯定会有所改进-我们接受PRs!:
---
Title: Test include
Published: 4/6/2019
Tags: [General]
---

# This page should contain the included content

^"test-include.html"
<h2>This should show in the post</h2>
<h1 id="this-page-should-contain-the-included-content">This page should contain the included content</h1>
<h2>This should show in the post</h2>
<h1 id="this-page-should-contain-the-included-content">This page should contain the included content</h1>
<p>^"test-include.html"</p>
---
Title: Test include
Published: 4/6/2019
Tags: [General]
---

# This page should contain the included content

<?# Include "test-include.html" /?>

---
Title: Test include
Published: 4/6/2019
Tags: [General]
---

# This page should contain the included content

<?! Include "test-include.md" /?>