@@ -16,7 +16,7 @@ import System.Directory (copyFile)
1616import Data.Maybe (fromMaybe)
1717import qualified Data.Map as M
1818
19−import Text.Hakyll.Context (Context)
19+import Text.Hakyll.Context (Context (..))
2020import Text.Hakyll.HakyllMonad (Hakyll, askHakyll, getAdditionalContext)
2121import Text.Hakyll.File
2222import Text.Hakyll.HakyllAction
@@ -27,12 +27,12 @@ import Text.Hakyll.Internal.Template
2727pureRender :: Template -- ^ Template to use for rendering.
2828 -> Context -- ^ Renderable object to render with given template.
2929 -> Context -- ^ The body of the result will contain the render.
30−pureRender template context =
30+pureRender template (Context c) =
3131 -- Ignore $root when substituting here. We will only replace that in the
3232 -- final render (just before writing).
33− let contextIgnoringRoot = M.insert "root" "$root" context
34− body = regularSubstitute template contextIgnoringRoot
35− in M.insert "body" body context
33+ let contextIgnoringRoot = Context $ M.insert "root" "$root" c
34+ body = regularSubstitute template $ contextIgnoringRoot
35+ in Context $ M.insert "body" body c
3636
3737-- | This is the most simple render action. You render a @Context@ with a
3838-- template, and get back the result.
@@ -68,7 +68,7 @@ renderAndConcat templatePaths renderables = HakyllAction
6868
6969 actionFunction' _ = do
7070 contexts <- mapM runHakyllAction renders
71− return $ concatMap (fromMaybe "" . M.lookup "body") contexts
71+ return $ concatMap (fromMaybe "" . M.lookup "body" . unContext) contexts
7272
7373-- | Chain a render action for a page with a number of templates. This will
7474-- also write the result to the site destination. This is the preferred way
@@ -112,8 +112,8 @@ css source = runHakyllActionIfNeeded css'
112112-- | Write a page to the site destination. Final action after render
113113-- chains and such.
114114writePage :: HakyllAction Context ()
115−writePage = createHakyllAction $ \initialContext -> do
116− additionalContext' <- askHakyll getAdditionalContext
115+writePage = createHakyllAction $ \(Context initialContext) -> do
116+ additionalContext' <- unContext <$> askHakyll getAdditionalContext
117117 let url = fromMaybe (error "No url defined at write time.")
118118 (M.lookup "url" initialContext)
119119 body = fromMaybe "" (M.lookup "body" initialContext)
@@ -121,4 +121,5 @@ writePage = createHakyllAction $ \initialContext -> do
121121 destination <- toDestination url
122122 makeDirectories destination
123123 -- Substitute $root here, just before writing.
124− liftIO $ writeFile destination $ finalSubstitute (fromString body) context
124+ liftIO $ writeFile destination $ finalSubstitute (fromString body)
125+ (Context context)