2017-10-08 27 views
0

在傑基爾有可能會有類似

--- 
title: Whatever 
layout: null 
--- 

<h1>{{ title }}</h1> 

{{ title }}將被插的文件,但layout: null意味着該文件的內容將不會被包裹在任何類型的模板。

Hakyll有什麼等價物?換句話說,如果我有一個自包含的文件中像

<h1>$title$</h1> 

什麼樣塊的,我需要傳遞給compile爲了有$title$值插值,沒有在一些模板包裹頁面的內容?

回答

0

答案(感謝erasmas在#hakyll通道!)是使用

getResourceBody >>= applyAsTemplate theContext 

其中theContextContext String包含要等領域的實例來編譯你的頁面。

這裏是你如何使用該編譯器的玩具例子:

main :: IO() 
main = hakyll $ do 
    match "index.html" $ do 
     route idRoute 
     compile $ getResourceBody >>= applyAsTemplate indexContext 

indexContext :: Context String 
indexContext = mconcat 
    [ constField "title" "My Website" 
    , defaultContext 
    ] 
相關問題