@@ -1,7 +1,7 @@
11-- | This module provides means for reading and applying 'Template's.
22--
3−-- Templates are tools to convert data (pages) into a string. They are
4−-- perfectly suited for laying out your site.
3+-- Templates are tools to convert items into a string. They are perfectly suited
4+-- for laying out your site.
55--
66-- Let's look at an example template:
77--
@@ -22,9 +22,6 @@
2222-- > </body>
2323-- > </html>
2424--
25−-- We can use this template to render a 'Page' which has a body and a @$title$@
26−-- metadata field.
27−--
2825-- As you can see, the format is very simple -- @$key$@ is used to render the
2926-- @$key$@ field from the page, everything else is literally copied. If you want
3027-- to literally insert @\"$key$\"@ into your page (for example, when you're
@@ -48,6 +45,7 @@ module Hakyll.Web.Template
4845
4946--------------------------------------------------------------------------------
5047import Control.Monad (forM, liftM)
48+import Data.Monoid (mappend)
5149import Prelude hiding (id)
5250
5351
@@ -74,7 +72,8 @@ applyTemplate :: Template -- ^ Template
7472 -> Item a -- ^ Page
7573 -> Compiler (Item String) -- ^ Resulting item
7674applyTemplate tpl context item = do
77− let context' k x = unContext context k x
75+ -- Appending missingField gives better error messages
76+ let context' k x = unContext (context `mappend` missingField) k x
7877 body <- applyTemplateWith context' tpl item
7978 return $ itemSetBody body item
8079