summaryrefslogtreecommitdiff
path: root/src/Hakyll/Web/Template
diff options
context:
space:
mode:
authorJasper Van der Jeugt <m@jaspervdj.be>2012-11-18 23:27:23 +0100
committerJasper Van der Jeugt <m@jaspervdj.be>2012-11-18 23:27:23 +0100
commit6b5c299ec945cdfea2dbf2df0922f8753588b729 (patch)
tree0b138a0bae36db8231e01109f2e3a68675ddb43b /src/Hakyll/Web/Template
parentf6c4fb849d00dfc5b197651ac062e9c38d6375f5 (diff)
downloadhakyll-6b5c299ec945cdfea2dbf2df0922f8753588b729.tar.gz
Fix feeds
Diffstat (limited to 'src/Hakyll/Web/Template')
-rw-r--r--src/Hakyll/Web/Template/Context.hs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/Hakyll/Web/Template/Context.hs b/src/Hakyll/Web/Template/Context.hs
index 269347b..fd9add9 100644
--- a/src/Hakyll/Web/Template/Context.hs
+++ b/src/Hakyll/Web/Template/Context.hs
@@ -3,6 +3,7 @@ module Hakyll.Web.Template.Context
( Context (..)
, mapContext
, field
+ , constField
, defaultContext
, bodyField
@@ -15,6 +16,7 @@ module Hakyll.Web.Template.Context
, dateFieldWith
, modificationTimeField
, modificationTimeFieldWith
+ , missingField
) where
@@ -64,6 +66,11 @@ field key value = Context $ \k i -> if k == key then value i else empty
--------------------------------------------------------------------------------
+constField :: String -> String -> Context a
+constField key = field key . const . return
+
+
+--------------------------------------------------------------------------------
defaultContext :: Context String
defaultContext =
bodyField "body" `mappend`
@@ -194,4 +201,6 @@ modificationTimeFieldWith locale key fmt = field key $ \i -> do
--------------------------------------------------------------------------------
missingField :: Context a
-missingField = Context $ \k _ -> return $ "$" ++ k ++ "$"
+missingField = Context $ \k i -> compilerThrow $
+ "Missing field $" ++ k ++ "$ in context for item " ++
+ show (itemIdentifier i)