summaryrefslogtreecommitdiff
path: root/src/Text/Hakyll/Render.hs
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2009-12-07 17:31:49 +0100
committerJasper Van der Jeugt <jaspervdj@gmail.com>2009-12-07 17:31:49 +0100
commit35e6572f6c30ffa9db61bb9ab71478cfb8d6aed1 (patch)
treee93fad57ca6905aa18d61ce4615a77df1e1d8d5a /src/Text/Hakyll/Render.hs
parent21196184f9135a552cef398c1e25ec101fcd604d (diff)
downloadhakyll-35e6572f6c30ffa9db61bb9ab71478cfb8d6aed1.tar.gz
Added general renderAndConcat function.
Diffstat (limited to 'src/Text/Hakyll/Render.hs')
-rw-r--r--src/Text/Hakyll/Render.hs12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/Text/Hakyll/Render.hs b/src/Text/Hakyll/Render.hs
index a69d27d..79f8764 100644
--- a/src/Text/Hakyll/Render.hs
+++ b/src/Text/Hakyll/Render.hs
@@ -1,6 +1,7 @@
module Text.Hakyll.Render
( renderPage,
renderAndWrite,
+ renderAndConcat,
static,
staticDirectory
) where
@@ -26,7 +27,7 @@ renderPage templatePath page = do
templateString <- liftM B.pack $ hGetContents handle
seq templateString $ hClose handle
let body = substitute templateString (createContext page)
- return $ addContext "body" (B.unpack body) page
+ return $ M.insert "body" body page
renderAndWrite :: FilePath -> Page -> IO ()
renderAndWrite templatePath page = do
@@ -35,6 +36,15 @@ renderAndWrite templatePath page = do
makeDirectories destination
B.writeFile destination (getBody rendered)
+renderAndConcat :: FilePath -> [FilePath] -> IO B.ByteString
+renderAndConcat templatePath paths = foldM concatRender' B.empty paths
+ where concatRender' :: B.ByteString -> FilePath -> IO B.ByteString
+ concatRender' chunk path = do
+ page <- readPage path
+ rendered <- renderPage templatePath page
+ let body = getBody rendered
+ return $ B.append chunk $ body
+
static :: FilePath -> IO ()
static source = do
makeDirectories destination