Copyright | © 2016–present Stack Builders |
---|---|
License | BSD 3 clause |
Maintainer | Mark Karpov <markkarpov92@gmail.com> |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
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
:: 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
:: (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
Compile a Mustache template and select it.
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