headroom-0.4.3.0: License Header Manager
Copyright(c) 2019-2022 Vaclav Svejcar
LicenseBSD-3-Clause
Maintainervaclav.svejcar@gmail.com
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone
LanguageHaskell2010

Headroom.Template

Description

Module providing interface for working with template files in extensible way. Supported template is represented by the Template type class.

Synopsis

Extendable Template Support

class Template a where Source #

Type class representing supported template file.

Methods

templateExtensions Source #

Arguments

:: NonEmpty Text

list of supported file extensions

Returns list of supported file extensions for this template type.

parseTemplate Source #

Arguments

:: MonadThrow m 
=> TemplateRef

reference to template source

-> Text

raw template text

-> m a

parsed template

Parses template from given raw text.

renderTemplate Source #

Arguments

:: MonadThrow m 
=> Variables

values of variables to replace

-> a

parsed template to render

-> m Text

rendered template text

Renders parsed template and replaces all variables with actual values.

rawTemplate Source #

Arguments

:: a

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.

templateRef Source #

Arguments

:: a

template for which to return reference

-> TemplateRef

template reference

Returns a reference to template source, from which this template was loaded.

Helper Functions

emptyTemplate :: (MonadThrow m, Template a) => m a Source #

Returns empty template of selected type.

Error Data Types

data TemplateError Source #

Error during processing template.

Constructors

MissingVariables Text [Text]

missing variable values

ParseError Text

error parsing raw template text