summaryrefslogtreecommitdiff
path: root/src/Text/Hakyll/Render
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2010-01-14 20:46:08 +0100
committerJasper Van der Jeugt <jaspervdj@gmail.com>2010-01-14 20:46:08 +0100
commit4bc34b8a98ffa1e7f3478a596b73c4ab12d9cb1b (patch)
tree86ff0e311ec49f794b28f973c95620918ab4f9ee /src/Text/Hakyll/Render
parent332f2f95cdb9c72e01a55eaf46c0b08bcf37d7e9 (diff)
downloadhakyll-4bc34b8a98ffa1e7f3478a596b73c4ab12d9cb1b.tar.gz
Added ReaderT to our stack.
Diffstat (limited to 'src/Text/Hakyll/Render')
-rw-r--r--src/Text/Hakyll/Render/Internal.hs15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/Text/Hakyll/Render/Internal.hs b/src/Text/Hakyll/Render/Internal.hs
index 3b9bfbb..379c4c9 100644
--- a/src/Text/Hakyll/Render/Internal.hs
+++ b/src/Text/Hakyll/Render/Internal.hs
@@ -11,6 +11,8 @@ module Text.Hakyll.Render.Internal
import qualified Data.Map as M
import Text.Hakyll.Context (Context, ContextManipulation)
+import Control.Monad.Reader (ask, liftIO)
+import Control.Monad (liftM)
import Data.List (isPrefixOf, foldl')
import Data.Char (isAlpha)
import Data.Maybe (fromMaybe)
@@ -18,6 +20,7 @@ import Control.Parallel.Strategies (rnf, ($|))
import Text.Hakyll.Renderable
import Text.Hakyll.Page
import Text.Hakyll.File
+import Text.Hakyll.Hakyll (Hakyll, hakyllGlobalContext)
-- | Substitutes `$identifiers` in the given string by values from the given
-- "Context". When a key is not found, it is left as it is. You can here
@@ -79,13 +82,13 @@ pureRenderChainWith manipulation templates context =
-- | Write a page to the site destination. Final action after render
-- chains and such.
-writePage :: Page -> IO ()
+writePage :: Page -> Hakyll ()
writePage page = do
+ globalContext <- liftM hakyllGlobalContext ask
let destination = toDestination url
- makeDirectories destination
- writeFile destination body
+ context = (M.singleton "root" $ toRoot url) `M.union` globalContext
+ liftIO $ makeDirectories destination
+    -- Substitute $root here, just before writing.
+ liftIO $ writeFile destination $ finalSubstitute (getBody page) context
where
url = getURL page
-    -- Substitute $root here, just before writing.
-    body = finalSubstitute (getBody page)
-                           (M.singleton "root" $ toRoot url)