headroom-0.4.1.0: License Header Manager
Copyright(c) 2019-2021 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 
=> Maybe Text

name of the template (optional)

-> 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.

Instances

Instances details
Template Mustache Source #

Support for Mustache templates.

Instance details

Defined in Headroom.Template.Mustache

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