summaryrefslogtreecommitdiff
path: root/src/Text/Hakyll/Render.hs
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2010-01-12 13:09:50 +0100
committerJasper Van der Jeugt <jaspervdj@gmail.com>2010-01-12 13:09:50 +0100
commitecd00b386e2848cab19c16afdcaeae3133f39569 (patch)
treeffe8445b3435c4e8bd9cd915ad0523aa10f3a9bd /src/Text/Hakyll/Render.hs
parentef7ccb15149862e1213ed66a31d65fc577c32d58 (diff)
downloadhakyll-ecd00b386e2848cab19c16afdcaeae3133f39569.tar.gz
Added pure renderChain function.
Diffstat (limited to 'src/Text/Hakyll/Render.hs')
-rw-r--r--src/Text/Hakyll/Render.hs15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/Text/Hakyll/Render.hs b/src/Text/Hakyll/Render.hs
index 649ad4b..c55e5d8 100644
--- a/src/Text/Hakyll/Render.hs
+++ b/src/Text/Hakyll/Render.hs
@@ -10,7 +10,7 @@ module Text.Hakyll.Render
, css
) where
-import Control.Monad (unless, liftM, foldM)
+import Control.Monad (unless, mapM, foldM)
import System.Directory (copyFile)
import System.IO
@@ -49,7 +49,7 @@ renderWith :: Renderable a
renderWith manipulation templatePath renderable = do
template <- readFile templatePath
context <- toContext renderable
- return $ pureRenderWith manipulation template context
+ return $ fromContext $ pureRenderWith manipulation template context
-- | Render each renderable with the given template, then concatenate the
-- result.
@@ -83,11 +83,12 @@ renderChain = renderChainWith id
-- "ContextManipulation" which to apply on the context when it is read first.
renderChainWith :: Renderable a
=> ContextManipulation -> [FilePath] -> a -> IO ()
-renderChainWith manipulation templates renderable =
- depends (getURL renderable) (getDependencies renderable ++ templates) $
- do initialPage <- liftM manipulation $ toContext renderable
- result <- foldM (flip render) (fromContext initialPage) templates
- writePage result
+renderChainWith manipulation templatePaths renderable =
+ depends (getURL renderable) (getDependencies renderable ++ templatePaths) $
+ do templates <- mapM readFile templatePaths
+ context <- toContext renderable
+ let result = pureRenderChainWith manipulation templates context
+ writePage $ fromContext result
-- | Mark a certain file as static, so it will just be copied when the site is
-- generated.