summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/example/site.hs2
-rw-r--r--src/Hakyll/Web/Template.hs10
-rw-r--r--tests/Hakyll/Web/Template/Tests.hs2
-rw-r--r--web/tutorials/04-compilers.markdown4
4 files changed, 13 insertions, 5 deletions
diff --git a/data/example/site.hs b/data/example/site.hs
index be041f8..2751f77 100644
--- a/data/example/site.hs
+++ b/data/example/site.hs
@@ -57,7 +57,7 @@ main = hakyll $ do
>>= loadAndApplyTemplate "templates/default.html" indexCtx
>>= relativizeUrls
- match "templates/*" $ compile templateCompiler
+ match "templates/*" $ compile templateBodyCompiler
--------------------------------------------------------------------------------
diff --git a/src/Hakyll/Web/Template.hs b/src/Hakyll/Web/Template.hs
index d28ce08..194949d 100644
--- a/src/Hakyll/Web/Template.hs
+++ b/src/Hakyll/Web/Template.hs
@@ -118,6 +118,7 @@
{-# LANGUAGE ScopedTypeVariables #-}
module Hakyll.Web.Template
( Template
+ , templateBodyCompiler
, templateCompiler
, applyTemplate
, loadAndApplyTemplate
@@ -143,7 +144,14 @@ import Hakyll.Web.Template.Internal
--------------------------------------------------------------------------------
--- | Read a template.
+-- | Read a template, without metadata header
+templateBodyCompiler :: Compiler (Item Template)
+templateBodyCompiler = cached "Hakyll.Web.Template.templateBodyCompiler" $ do
+ item <- getResourceBody
+ return $ fmap readTemplate item
+
+--------------------------------------------------------------------------------
+-- | Read complete file contents as a template
templateCompiler :: Compiler (Item Template)
templateCompiler = cached "Hakyll.Web.Template.templateCompiler" $ do
item <- getResourceString
diff --git a/tests/Hakyll/Web/Template/Tests.hs b/tests/Hakyll/Web/Template/Tests.hs
index ea3a9b2..a975901 100644
--- a/tests/Hakyll/Web/Template/Tests.hs
+++ b/tests/Hakyll/Web/Template/Tests.hs
@@ -51,7 +51,7 @@ case01 = do
out <- resourceString provider "template.html.out"
tpl <- testCompilerDone store provider "template.html" $
- templateCompiler
+ templateBodyCompiler
item <- testCompilerDone store provider "example.md" $
pandocCompiler >>= applyTemplate (itemBody tpl) testContext
diff --git a/web/tutorials/04-compilers.markdown b/web/tutorials/04-compilers.markdown
index 49935e1..d283e9a 100644
--- a/web/tutorials/04-compilers.markdown
+++ b/web/tutorials/04-compilers.markdown
@@ -53,10 +53,10 @@ when the template is applied. If you want an actual dollar sign in the output,
use `$$`.
You usually compile the templates from disk using the aptly named
-`templateCompiler`:
+`templateBodyCompiler`:
```haskell
-match "templates/*" $ compile templateCompiler
+match "templates/*" $ compile templateBodyCompiler
```
Notice the lack of `route` here: this is because we don't need to write the