1

我刚开始使用 Hakyll,并且正在使用hakyll init. 我尝试将以下内容放入2015-08-12.spqr.markdown

$partial("includes/DB.hs")$

它没有按预期工作 - 帖子只是显示了文字文本$partial("includes/DB.hs")$。它没有将内容拉includes/DB.hs入帖子中。然后我尝试将以下内容添加到site.hs,但即使这样也没有用:

match "includes/*" $ compile templateBodyCompiler

我错过了什么?

4

1 回答 1

4

部分仅在模板内被识别。您需要使用templateCompiler或使用编译帖子applyAsTemplate。您可以在示例的index.html编译中看到它。

applyAsTemplate当您还想进一步转换文本时特别有用,例如处理降价:

compile $ do
    getResourceString
        >>= applyAsTemplate someContext -- e.g. defaultContext
        >>= renderPandoc
        >>= loadAndApplyTemplate "templates/default.html" indexCtx
        >>= relativizeUrls
于 2016-11-21T05:24:36.407 回答