heterocephalus-1.0.0.2: A type safe template engine for collaborating with front end development tools

Safe HaskellNone
LanguageHaskell2010

Text.Heterocephalus

Contents

Synopsis

Core functions

compileText :: QuasiQuoter Source #

Heterocephalus quasi-quoter. This function DOES NOT escape template variables. To render the compiled file, use Text.Blaze.Renderer.*.renderMarkup.

>>> renderMarkup (let as = ["<a>", "b"] in [compileText|sample %{ forall a <- as }key: #{a}, %{ endforall }|])
"sample key: <a>, key: b, "
>>> renderMarkup (let num=2 in [compileText|#{num} is %{ if even num }even number.%{ else }odd number.%{ endif }|])
"2 is even number."

compileTextFile :: FilePath -> Q Exp Source #

Heterocephalus quasi-quoter. Same as compileText but this function read template literal from an external file.

>>> putStr $ renderMarkup (let as = ["<a>", "b"] in $(compileTextFile "templates/sample.txt"))
sample
key: <a>,
key: b,

compileHtml :: QuasiQuoter Source #

Heterocephalus quasi-quoter for Html. Same as compileText but this function do escape template variables for Html.

>>> renderMarkup (let as = ["<a>", "b"] in [compileHtml|sample %{ forall a <- as }key: #{a}, %{ endforall }|])
"sample key: &lt;a&gt;, key: b, "

compileHtmlFile :: FilePath -> Q Exp Source #

Heterocephalus quasi-quoter. Same as compileTextFile but escapes template variables for Html.

>>> putStr $ renderMarkup (let as = ["<a>", "b"] in $(compileHtmlFile "templates/sample.txt"))
sample
key: &lt;a&gt;,
key: b,

low-level

compileFile :: HeterocephalusSetting -> FilePath -> Q Exp Source #

Compile a template file.