summaryrefslogtreecommitdiff
path: root/src/Hakyll/Web/Template/Internal.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Hakyll/Web/Template/Internal.hs')
-rw-r--r--src/Hakyll/Web/Template/Internal.hs20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/Hakyll/Web/Template/Internal.hs b/src/Hakyll/Web/Template/Internal.hs
index 6a9947f..15266a0 100644
--- a/src/Hakyll/Web/Template/Internal.hs
+++ b/src/Hakyll/Web/Template/Internal.hs
@@ -7,6 +7,7 @@ module Hakyll.Web.Template.Internal
, TemplateElement (..)
, templateElems
, readTemplateElems
+ , readTemplateElemsFile
) where
@@ -108,7 +109,12 @@ instance Binary TemplateExpr where
--------------------------------------------------------------------------------
readTemplateElems :: String -> [TemplateElement]
-readTemplateElems input = case P.parse templateElems "" input of
+readTemplateElems = readTemplateElemsFile "{literal}"
+
+
+--------------------------------------------------------------------------------
+readTemplateElemsFile :: FilePath -> String -> [TemplateElement]
+readTemplateElemsFile file input = case P.parse templateElems file input of
Left err -> error $ "Cannot parse template: " ++ show err
Right t -> t
@@ -116,12 +122,12 @@ readTemplateElems input = case P.parse templateElems "" input of
--------------------------------------------------------------------------------
templateElems :: P.Parser [TemplateElement]
templateElems = mconcat <$> P.many (P.choice [ lift chunk
- , lift escaped
- , conditional
- , for
- , partial
- , expr
- ])
+ , lift escaped
+ , conditional
+ , for
+ , partial
+ , expr
+ ])
where lift = fmap (:[])