stache-2.3.3: Mustache templates for Haskell
Copyright© 2016–present Stack Builders
LicenseBSD 3 clause
MaintainerMark Karpov <markkarpov92@gmail.com>
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Text.Mustache.Compile.TH

Description

Template Haskell helpers to compile Mustache templates at compile time. This module is not imported as part of Text.Mustache, so you need to import it yourself. Qualified import is recommended, but not necessary.

Synopsis

Documentation

compileMustacheDir Source #

Arguments

:: PName

Which template to select after compiling

-> FilePath

Directory with templates

-> Q Exp

The resulting template

Compile all templates in the specified directory and select one. Template files should have the extension mustache, (e.g. foo.mustache) to be recognized. This function does not scan the directory recursively.

This version compiles the templates at compile time.

compileMustacheDir = compileMustacheDir' isMustacheFile

compileMustacheDir' Source #

Arguments

:: (FilePath -> Bool)

Template selection predicate

-> PName

Which template to select after compiling

-> FilePath

Directory with templates

-> Q Exp

The resulting template

The same as compileMustacheDir, but allows using a custom predicate for template selection.

This version compiles the templates at compile time.

Since: 1.2.0

compileMustacheFile Source #

Arguments

:: FilePath

Location of the file

-> Q Exp 

Compile a Mustache template and select it.

This version compiles the template at compile time.

compileMustacheText Source #

Arguments

:: PName

How to name the template?

-> Text

The template to compile

-> Q Exp 

Compile a Mustache template from Text value. The cache will contain only this template named according to given Key.

This version compiles the template at compile time.

mustache :: QuasiQuoter Source #

Compile a Mustache using a QuasiQuoter. Usage:

{-# LANGUAGE QuasiQuotes #-}
import Text.Mustache.Compile.TH (mustache)

foo :: Template
foo = [mustache|This is my inline {{ template }}.|]

Name of created partial is set to "quasi-quoted". You can extend cache of Template created this way using (<>) and so work with partials as usual.

Since: 0.1.7