diff options
Diffstat (limited to 'src/Hakyll/Web/Template.hs')
| -rw-r--r-- | src/Hakyll/Web/Template.hs | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/Hakyll/Web/Template.hs b/src/Hakyll/Web/Template.hs index 45d1b92..76911e0 100644 --- a/src/Hakyll/Web/Template.hs +++ b/src/Hakyll/Web/Template.hs @@ -87,14 +87,18 @@ applyTemplate' tpl context x = go tpl context' = unContext (context `mappend` missingField) go = liftM concat . mapM applyElem . unTemplate - applyElem (Chunk c) = return c - applyElem Escaped = return "$" - applyElem (Key k) = context' k x >>= getString k + applyElem (Chunk c) = return c + + applyElem Escaped = return "$" + + applyElem (Key k) = context' k x >>= getString k + applyElem (If k t mf) = (context' k x >> go t) `catchError` handler where handler _ = case mf of Nothing -> return "" Just f -> go f + applyElem (For k b s) = context' k x >>= \cf -> case cf of StringField _ -> fail $ "Hakyll.Web.Template.applyTemplateWith: expected ListField but " ++ @@ -104,6 +108,10 @@ applyTemplate' tpl context x = go tpl bs <- mapM (applyTemplate' b c) xs return $ intercalate sep bs + applyElem (Partial p) = do + tpl' <- loadBody (fromFilePath p) + applyTemplate' tpl' context x + getString _ (StringField s) = return s getString k (ListField _ _) = fail $ "Hakyll.Web.Template.applyTemplateWith: expected StringField but " ++ |
