From 871cfd36ddd143f8fad14657e1c1fd80a9e6c66f Mon Sep 17 00:00:00 2001 From: Lorenzo Date: Sat, 23 Jul 2016 12:31:03 +0200 Subject: Include file name in error messages --- src/Hakyll/Web/Template/Internal.hs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/Hakyll/Web/Template') diff --git a/src/Hakyll/Web/Template/Internal.hs b/src/Hakyll/Web/Template/Internal.hs index aa8e080..a63c40d 100644 --- a/src/Hakyll/Web/Template/Internal.hs +++ b/src/Hakyll/Web/Template/Internal.hs @@ -8,6 +8,7 @@ module Hakyll.Web.Template.Internal , TemplateExpr (..) , TemplateElement (..) , readTemplate + , readTemplateFile ) where @@ -120,10 +121,16 @@ instance Binary TemplateExpr where -------------------------------------------------------------------------------- readTemplate :: String -> Template -readTemplate input = case P.parse topLevelTemplate "" input of +readTemplate = readTemplateFile "{literal}" + + +-------------------------------------------------------------------------------- +readTemplateFile :: FilePath -> String -> Template +readTemplateFile file input = case P.parse topLevelTemplate file input of Left err -> error $ "Cannot parse template: " ++ show err Right t -> t + -------------------------------------------------------------------------------- topLevelTemplate :: P.Parser Template topLevelTemplate = Template <$> -- cgit v1.2.3