mirror of
https://github.com/ilyakooo0/hakyll.git
synced 2024-10-06 09:17:15 +03:00
Merge pull request #448 from lortabac/master
Fail if template is not parsed until eof
This commit is contained in:
commit
ccced51cf4
@ -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
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user