From aa44d6c0da442887155a47c77f03209224517af0 Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Sun, 17 Jan 2010 12:37:55 +0100 Subject: Documentation++. --- src/Text/Hakyll/Render.hs | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) (limited to 'src/Text/Hakyll/Render.hs') 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 -- cgit v1.2.3