Text.Mustache.Compile.TH

stache-2.3.4: Mustache templates for Haskell

Copyright | © 2016–present Stack Builders
License | BSD 3 clause
Maintainer | Mark Karpov <markkarpov92@gmail.com>
Stability | experimental
Portability | portable
Safe Haskell | None
Language | Haskell2010

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

- compileMustacheDir :: PName -> FilePath -> Q Exp
- compileMustacheDir' :: (FilePath -> Bool) -> PName -> FilePath -> Q Exp
- compileMustacheFile :: FilePath -> Q Exp
- compileMustacheText :: PName -> Text -> Q Exp
- mustache :: QuasiQuoter

# Documentation

compileMustacheDir #

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' #

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 #

Arguments

:: FilePath | Location of the file
-> Q Exp |

Compile a Mustache template and select it.

This version compiles the template at compile time.

compileMustacheText #

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 #

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