@@ -16,7 +16,7 @@ import System.Directory (copyFile)
16import Data.Maybe (fromMaybe)
16import Data.Maybe (fromMaybe)
17import qualified Data.Map as M
17import qualified Data.Map as M
19−import Text.Hakyll.Context (Context)
19+import Text.Hakyll.Context (Context (..))
20import Text.Hakyll.HakyllMonad (Hakyll, askHakyll, getAdditionalContext)
20import Text.Hakyll.HakyllMonad (Hakyll, askHakyll, getAdditionalContext)
21import Text.Hakyll.File
21import Text.Hakyll.File
22import Text.Hakyll.HakyllAction
22import Text.Hakyll.HakyllAction
@@ -27,12 +27,12 @@ import Text.Hakyll.Internal.Template
27pureRender :: Template -- ^ Template to use for rendering.
27pureRender :: Template -- ^ Template to use for rendering.
28 -> Context -- ^ Renderable object to render with given template.
28 -> Context -- ^ Renderable object to render with given template.
29 -> Context -- ^ The body of the result will contain the render.
29 -> Context -- ^ The body of the result will contain the render.
30−pureRender template context =
30+pureRender template (Context c) =
31 -- Ignore $root when substituting here. We will only replace that in the
31 -- Ignore $root when substituting here. We will only replace that in the
32 -- final render (just before writing).
32 -- final render (just before writing).
33− let contextIgnoringRoot = M.insert "root" "$root" context
33+ let contextIgnoringRoot = Context $ M.insert "root" "$root" c
34− body = regularSubstitute template contextIgnoringRoot
34+ body = regularSubstitute template $ contextIgnoringRoot
35− in M.insert "body" body context
35+ in Context $ M.insert "body" body c
37-- | This is the most simple render action. You render a @Context@ with a
37-- | This is the most simple render action. You render a @Context@ with a
38-- template, and get back the result.
38-- template, and get back the result.
@@ -68,7 +68,7 @@ renderAndConcat templatePaths renderables = HakyllAction
69 actionFunction' _ = do
69 actionFunction' _ = do
70 contexts <- mapM runHakyllAction renders
70 contexts <- mapM runHakyllAction renders
71− return $ concatMap (fromMaybe "" . M.lookup "body") contexts
71+ return $ concatMap (fromMaybe "" . M.lookup "body" . unContext) contexts
73-- | Chain a render action for a page with a number of templates. This will
73-- | Chain a render action for a page with a number of templates. This will
74-- also write the result to the site destination. This is the preferred way
74-- also write the result to the site destination. This is the preferred way
@@ -112,8 +112,8 @@ css source = runHakyllActionIfNeeded css'
112-- | Write a page to the site destination. Final action after render
112-- | Write a page to the site destination. Final action after render
113-- chains and such.
113-- chains and such.
114writePage :: HakyllAction Context ()
114writePage :: HakyllAction Context ()
115−writePage = createHakyllAction $ \initialContext -> do
115+writePage = createHakyllAction $ \(Context initialContext) -> do
116− additionalContext' <- askHakyll getAdditionalContext
116+ additionalContext' <- unContext <$> askHakyll getAdditionalContext
117 let url = fromMaybe (error "No url defined at write time.")
117 let url = fromMaybe (error "No url defined at write time.")
118 (M.lookup "url" initialContext)
118 (M.lookup "url" initialContext)
119 body = fromMaybe "" (M.lookup "body" initialContext)
119 body = fromMaybe "" (M.lookup "body" initialContext)
@@ -121,4 +121,5 @@ writePage = createHakyllAction $ \initialContext -> do
121 destination <- toDestination url
121 destination <- toDestination url
122 makeDirectories destination
122 makeDirectories destination
123 -- Substitute $root here, just before writing.
123 -- Substitute $root here, just before writing.
124− liftIO $ writeFile destination $ finalSubstitute (fromString body) context
124+ liftIO $ writeFile destination $ finalSubstitute (fromString body)