Copyright | (c) 2019-2020 Vaclav Svejcar |
---|---|
License | BSD-3-Clause |
Maintainer | vaclav.svejcar@gmail.com |
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
Module providing generic representation of supported template type, using
the Template
type class.
Synopsis
- class Template t where
- templateExtensions :: NonEmpty Text
- parseTemplate :: MonadThrow m => Maybe Text -> Text -> m t
- renderTemplate :: MonadThrow m => Variables -> t -> m Text
- rawTemplate :: t -> Text
- data TemplateError
- = MissingVariables !Text ![Text]
- | ParseError !Text
Documentation
class Template t where Source #
Type class representing generic license header template support.
Returns list of supported file extensions for this template type.
:: MonadThrow m | |
=> Maybe Text | name of the template (optional) |
-> Text | raw template text |
-> m t | parsed template |
Parses template from given raw text.
:: MonadThrow m | |
=> Variables | values of variables to replace |
-> t | parsed template to render |
-> m Text | rendered template text |
Renders parsed template and replaces all variables with actual values.
:: t | template for which to return raw template text |
-> Text | raw template text |
Returns the raw text of the template, same that has been parsed by
parseTemplate
method.
Instances
Template Mustache Source # | Support for Mustache templates. |
Defined in Headroom.Template.Mustache templateExtensions :: NonEmpty Text Source # parseTemplate :: MonadThrow m => Maybe Text -> Text -> m Mustache Source # renderTemplate :: MonadThrow m => Variables -> Mustache -> m Text Source # rawTemplate :: Mustache -> Text Source # |
data TemplateError Source #
Error during processing template.
MissingVariables !Text ![Text] | missing variable values |
ParseError !Text | error parsing raw template text |
Instances
Eq TemplateError Source # | |
Defined in Headroom.Template (==) :: TemplateError -> TemplateError -> Bool # (/=) :: TemplateError -> TemplateError -> Bool # | |
Show TemplateError Source # | |
Defined in Headroom.Template showsPrec :: Int -> TemplateError -> ShowS # show :: TemplateError -> String # showList :: [TemplateError] -> ShowS # | |
Exception TemplateError Source # | |
Defined in Headroom.Template |