Generalize ReadTemplate

This commit is contained in:
2024-10-05 17:59:52 +02:00
parent 7801371534
commit 1988beb49a
3 changed files with 9 additions and 7 deletions

View File

@@ -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)