summaryrefslogtreecommitdiff
path: root/src/Text/Hakyll/Render.hs
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2010-01-12 08:40:44 +0100
committerJasper Van der Jeugt <jaspervdj@gmail.com>2010-01-12 08:40:44 +0100
commit0152a15b1e625b447ccb9d8a7956d026b401c31a (patch)
tree56f18164131cd24081711503b343a48cfffac164 /src/Text/Hakyll/Render.hs
parent53d9ba21932873eafe82e395077378b05152d311 (diff)
downloadhakyll-0152a15b1e625b447ccb9d8a7956d026b401c31a.tar.gz
Some more strictness.
Diffstat (limited to 'src/Text/Hakyll/Render.hs')
-rw-r--r--src/Text/Hakyll/Render.hs5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/Text/Hakyll/Render.hs b/src/Text/Hakyll/Render.hs
index caf0221..58a8d4d 100644
--- a/src/Text/Hakyll/Render.hs
+++ b/src/Text/Hakyll/Render.hs
@@ -25,6 +25,8 @@ import Text.Hakyll.Renderable
import Text.Hakyll.File
import Text.Hakyll.CompressCSS
+import Control.Parallel.Strategies (rnf, ($|))
+
-- | Execute an IO action only when the cache is invalid.
depends :: FilePath -- ^ File to be rendered or created.
-> [FilePath] -- ^ Files the render depends on.
@@ -75,12 +77,13 @@ renderWith :: Renderable a
renderWith manipulation templatePath renderable = do
handle <- openFile templatePath ReadMode
templateString <- hGetContents handle
- seq templateString $ hClose handle
context <- liftM manipulation $ toContext renderable
-- Ignore $root when substituting here. We will only replace that in the
-- final render (just before writing).
let contextIgnoringRoot = M.insert "root" "$root" context
body = regularSubstitute templateString contextIgnoringRoot
+ -- Force the body to be rendered before closing the handle.
+ seq (($|) id rnf body) $ hClose handle
return $ fromContext (M.insert "body" body context)
-- | Render each renderable with the given template, then concatenate the