summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJasper Van der Jeugt <m@jaspervdj.be>2013-01-14 10:47:04 +0100
committerJasper Van der Jeugt <m@jaspervdj.be>2013-01-14 10:47:04 +0100
commit4280b75ef67a0c2224198ad1b30bd100cc56f7a4 (patch)
tree0456328410db744bfb048574aaa90f27c44eeb83 /src
parent82a725bd8f59453cacf3ff5e45b3a7d2903dbb2f (diff)
downloadhakyll-4280b75ef67a0c2224198ad1b30bd100cc56f7a4.tar.gz
Append missingField before applying templates
This gives better errror messages in some cases
Diffstat (limited to 'src')
-rw-r--r--src/Hakyll/Core/Compiler.hs2
-rw-r--r--src/Hakyll/Web/Template.hs11
2 files changed, 6 insertions, 7 deletions
diff --git a/src/Hakyll/Core/Compiler.hs b/src/Hakyll/Core/Compiler.hs
index ca43201..dcaf2f0 100644
--- a/src/Hakyll/Core/Compiler.hs
+++ b/src/Hakyll/Core/Compiler.hs
@@ -48,7 +48,7 @@ import qualified Hakyll.Core.Store as Store
--------------------------------------------------------------------------------
--- | Get the underlying identifier. Only use this if you know what you're doing.
+-- | Get the underlying identifier.
getUnderlying :: Compiler Identifier
getUnderlying = compilerUnderlying <$> compilerAsk
diff --git a/src/Hakyll/Web/Template.hs b/src/Hakyll/Web/Template.hs
index 761c3ad..07a8ff3 100644
--- a/src/Hakyll/Web/Template.hs
+++ b/src/Hakyll/Web/Template.hs
@@ -1,7 +1,7 @@
-- | This module provides means for reading and applying 'Template's.
--
--- Templates are tools to convert data (pages) into a string. They are
--- perfectly suited for laying out your site.
+-- Templates are tools to convert items into a string. They are perfectly suited
+-- for laying out your site.
--
-- Let's look at an example template:
--
@@ -22,9 +22,6 @@
-- > </body>
-- > </html>
--
--- We can use this template to render a 'Page' which has a body and a @$title$@
--- metadata field.
---
-- As you can see, the format is very simple -- @$key$@ is used to render the
-- @$key$@ field from the page, everything else is literally copied. If you want
-- to literally insert @\"$key$\"@ into your page (for example, when you're
@@ -48,6 +45,7 @@ module Hakyll.Web.Template
--------------------------------------------------------------------------------
import Control.Monad (forM, liftM)
+import Data.Monoid (mappend)
import Prelude hiding (id)
@@ -74,7 +72,8 @@ applyTemplate :: Template -- ^ Template
-> Item a -- ^ Page
-> Compiler (Item String) -- ^ Resulting item
applyTemplate tpl context item = do
- let context' k x = unContext context k x
+ -- Appending missingField gives better error messages
+ let context' k x = unContext (context `mappend` missingField) k x
body <- applyTemplateWith context' tpl item
return $ itemSetBody body item