summaryrefslogtreecommitdiff
path: root/src/Text/Hakyll/Render.hs
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2010-01-17 12:37:55 +0100
committerJasper Van der Jeugt <jaspervdj@gmail.com>2010-01-17 12:37:55 +0100
commitaa44d6c0da442887155a47c77f03209224517af0 (patch)
treeb9c1d8fe6bed4eb1922d737f8817d851d8a34f5d /src/Text/Hakyll/Render.hs
parent003734442486876153911d339f07d4379e8dca20 (diff)
downloadhakyll-aa44d6c0da442887155a47c77f03209224517af0.tar.gz
Documentation++.
Diffstat (limited to 'src/Text/Hakyll/Render.hs')
-rw-r--r--src/Text/Hakyll/Render.hs34
1 files changed, 26 insertions, 8 deletions
diff --git a/src/Text/Hakyll/Render.hs b/src/Text/Hakyll/Render.hs
index c529d04..47ce287 100644
--- a/src/Text/Hakyll/Render.hs
+++ b/src/Text/Hakyll/Render.hs
@@ -52,27 +52,45 @@ renderWith manipulation templatePath renderable = do
context <- toContext renderable
return $ fromContext $ pureRenderWith manipulation template context
--- | Render each renderable with the given template, then concatenate the
--- result.
-renderAndConcat :: Renderable a => FilePath -> [a] -> Hakyll String
+-- | Render each renderable with the given templates, then concatenate the
+-- result. So, basically this function:
+--
+-- * Takes every renderable.
+--
+-- * Renders every renderable with all given templates. This is comparable
+-- with a renderChain action.
+--
+-- * Concatenates the result.
+--
+renderAndConcat :: Renderable a
+ => [FilePath] -- ^ Templates to apply on every renderable.
+ -> [a] -- ^ Renderables to render.
+ -> Hakyll String
renderAndConcat = renderAndConcatWith id
--- | Render each renderable with the given template, then concatenate the
+-- | Render each renderable with the given templates, then concatenate the
-- result. This function allows you to specify a "ContextManipulation" to
-- apply on every "Renderable".
renderAndConcatWith :: Renderable a
=> ContextManipulation
- -> FilePath
+ -> [FilePath]
-> [a]
-> Hakyll String
-renderAndConcatWith manipulation templatePath renderables = do
- template <- liftIO $ readFile templatePath
+renderAndConcatWith manipulation templatePaths renderables = do
+ templates <- liftIO $ mapM readFile templatePaths
contexts <- mapM toContext renderables
- return $ pureRenderAndConcatWith manipulation template contexts
+ return $ pureRenderAndConcatWith manipulation templates contexts
-- | Chain a render action for a page with a number of templates. This will
-- also write the result to the site destination. This is the preferred way
-- to do general rendering.
+--
+-- > renderChain [ "templates/notice.html"
+-- > , "templates/default.html"
+-- > ] $ createPagePath "warning.html"
+--
+-- This code will first render @warning.html@ using @templates/notice.html@,
+-- and will then render the result with @templates/default.html@.
renderChain :: Renderable a => [FilePath] -> a -> Hakyll ()
renderChain = renderChainWith id