Generalize ReadTemplate
This commit is contained in:
@@ -24,10 +24,9 @@ evalFunctionIO f x = case (f, x) of
|
||||
(IsDirectory, String (StringWrapper s)) ->
|
||||
Bool <$> doesDirectoryExist s
|
||||
|
||||
(ReadTemplate, String (StringWrapper s)) -> do
|
||||
(ReadTemplate, Tuple (String (StringWrapper s), Text c)) -> do
|
||||
t <- T.readFile s
|
||||
let c = "CONTENT"
|
||||
(beforeContent, after) = T.breakOn c t
|
||||
let (beforeContent, after) = T.breakOn c t
|
||||
afterContent = T.drop (T.length c) after
|
||||
pure $ Template $ TemplateParts beforeContent afterContent
|
||||
|
||||
@@ -62,4 +61,4 @@ evalFunctionIO f x = case (f, x) of
|
||||
pure $ Text $ TL.toStrict $ B.renderHtml html
|
||||
|
||||
_ ->
|
||||
error "unexpected combination of function and argument type"
|
||||
error ("unexpected combination of function and argument type; got function " ++ show f ++ " with argument " ++ show x)
|
||||
|
||||
Reference in New Issue
Block a user