karver
karver copied to clipboard
make `renderTemplate` total
right now a non-existent include raises an error and parse errors or lookup errors in the context will just render nonsensical text without the calling application being aware of it.
i would need renderTemplate
to return Either KarverError Text
with a suitable data KarverError = InvalidTemplate LineNo ColumnNo Text | NoSuchInclude Text | ...
.
i propose the following change to renderTemplate
, so that the current behavior is still possible. add another argument to renderTemplate
that decides what to do. e.g. renderTemplate :: (KarverError -> Either a Text) -> HashMap Text Value -> Text -> Either a Text
.
what do you think?
see my branch https://github.com/ibotty/karver/tree/total-renderTemplate for one approach requiring a new transformers release.
Yes I do think that karver need some error handling, and for that reason I will leave this issue open. I'm not going to worry that much about it until I get more of the features of the actual templating part complete.