| Copyright | (c) 2019-2020 Vaclav Svejcar |
|---|---|
| License | BSD-3-Clause |
| Maintainer | vaclav.svejcar@gmail.com |
| Stability | experimental |
| Portability | POSIX |
| Safe Haskell | None |
| Language | Haskell2010 |
Headroom.Template
Description
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.
Methods
Returns list of supported file extensions for this template type.
Arguments
| :: MonadThrow m | |
| => Maybe Text | name of the template (optional) |
| -> Text | raw template text |
| -> m t | parsed template |
Parses template from given raw text.
Arguments
| :: 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.
Arguments
| :: 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 Methods 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.
Constructors
| MissingVariables !Text ![Text] | missing variable values |
| ParseError !Text | error parsing raw template text |
Instances
| Eq TemplateError Source # | |
Defined in Headroom.Template Methods (==) :: TemplateError -> TemplateError -> Bool # (/=) :: TemplateError -> TemplateError -> Bool # | |
| Show TemplateError Source # | |
Defined in Headroom.Template Methods showsPrec :: Int -> TemplateError -> ShowS # show :: TemplateError -> String # showList :: [TemplateError] -> ShowS # | |
| Exception TemplateError Source # | |
Defined in Headroom.Template Methods toException :: TemplateError -> SomeException # fromException :: SomeException -> Maybe TemplateError # displayException :: TemplateError -> String # | |