on master help sign in
templateBodyCompiler compiles resource body only

and becomes the new default, instead of templateCompiler fixes #378

commit5a4ae4147313f52d50ff3bd9d74340a86175a5d9 authorBergi <a.d.bergi@web.de> dateWed 21 Oct 2015, 22:14 (11 years ago) parent8dec0a5
4 files changed+13−5
data/example/site.hs+1−1 src/Hakyll/Web/Template.hs+9−1 tests/Hakyll/Web/Template/Tests.hs+1−1 web/tutorials/04-compilers.markdown+2−2
data/example/site.hs+1−1
@@ -57,7 +57,7 @@ main = hakyll $ do
5757 >>= loadAndApplyTemplate "templates/default.html" indexCtx
5858 >>= relativizeUrls
5959
60− match "templates/*" $ compile templateCompiler
60+ match "templates/*" $ compile templateBodyCompiler
6161
6262
6363--------------------------------------------------------------------------------
src/Hakyll/Web/Template.hs+9−1
@@ -118,6 +118,7 @@
118118{-# LANGUAGE ScopedTypeVariables #-}
119119module Hakyll.Web.Template
120120 ( Template
121+ , templateBodyCompiler
121122 , templateCompiler
122123 , applyTemplate
123124 , loadAndApplyTemplate
@@ -143,7 +144,14 @@ import Hakyll.Web.Template.Internal
143144
144145
145146--------------------------------------------------------------------------------
146−-- | Read a template.
147+-- | Read a template, without metadata header
148+templateBodyCompiler :: Compiler (Item Template)
149+templateBodyCompiler = cached "Hakyll.Web.Template.templateBodyCompiler" $ do
150+ item <- getResourceBody
151+ return $ fmap readTemplate item
152+
153+--------------------------------------------------------------------------------
154+-- | Read complete file contents as a template
147155templateCompiler :: Compiler (Item Template)
148156templateCompiler = cached "Hakyll.Web.Template.templateCompiler" $ do
149157 item <- getResourceString
tests/Hakyll/Web/Template/Tests.hs+1−1
@@ -51,7 +51,7 @@ case01 = do
5151
5252 out <- resourceString provider "template.html.out"
5353 tpl <- testCompilerDone store provider "template.html" $
54− templateCompiler
54+ templateBodyCompiler
5555 item <- testCompilerDone store provider "example.md" $
5656 pandocCompiler >>= applyTemplate (itemBody tpl) testContext
5757
web/tutorials/04-compilers.markdown+2−2
@@ -53,10 +53,10 @@ when the template is applied. If you want an actual dollar sign in the output,
5353use `$$`.
5454
5555You usually compile the templates from disk using the aptly named
56−`templateCompiler`:
56+`templateBodyCompiler`:
5757
5858```haskell
59−match "templates/*" $ compile templateCompiler
59+match "templates/*" $ compile templateBodyCompiler
6060```
6161
6262Notice the lack of `route` here: this is because we don't need to write the