templateBodyCompiler compiles resource body only

and becomes the new default, instead of templateCompiler

fixes #378
This commit is contained in:
Bergi 2015-10-21 22:14:39 +02:00
parent 8dec0a51fb
commit 5a4ae41473
4 changed files with 13 additions and 5 deletions

View file

@ -57,7 +57,7 @@ main = hakyll $ do
>>= loadAndApplyTemplate "templates/default.html" indexCtx
>>= relativizeUrls
match "templates/*" $ compile templateCompiler
match "templates/*" $ compile templateBodyCompiler
--------------------------------------------------------------------------------

View file

@ -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

View file

@ -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

View file

@ -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