summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2016-07-22 17:47:30 +0200
committerGitHub <noreply@github.com>2016-07-22 17:47:30 +0200
commitccced51cf44f07babc828b38a8859c0b223dbb78 (patch)
tree4d397eb270aaeef5b42707c21f3ec37cead1f50e
parentcb07202f5af0ac64f9aa4ccde9e9917f3ed01ed3 (diff)
parent7a1989d288ac9f2e0d38e8f84509895c33780046 (diff)
downloadhakyll-ccced51cf44f07babc828b38a8859c0b223dbb78.tar.gz
Merge pull request #448 from lortabac/master
Fail if template is not parsed until eof
-rw-r--r--src/Hakyll/Web/Template/Internal.hs13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/Hakyll/Web/Template/Internal.hs b/src/Hakyll/Web/Template/Internal.hs
index 45db2e4..aa8e080 100644
--- a/src/Hakyll/Web/Template/Internal.hs
+++ b/src/Hakyll/Web/Template/Internal.hs
@@ -120,15 +120,22 @@ instance Binary TemplateExpr where
--------------------------------------------------------------------------------
readTemplate :: String -> Template
-readTemplate input = case P.parse template "" input of
+readTemplate input = case P.parse topLevelTemplate "" input of
Left err -> error $ "Cannot parse template: " ++ show err
Right t -> t
+--------------------------------------------------------------------------------
+topLevelTemplate :: P.Parser Template
+topLevelTemplate = Template <$>
+ P.manyTill templateElement P.eof
--------------------------------------------------------------------------------
template :: P.Parser Template
-template = Template <$>
- (P.many $ chunk <|> escaped <|> conditional <|> for <|> partial <|> expr)
+template = Template <$> P.many templateElement
+
+--------------------------------------------------------------------------------
+templateElement :: P.Parser TemplateElement
+templateElement = chunk <|> escaped <|> conditional <|> for <|> partial <|> expr
--------------------------------------------------------------------------------