microstache-1: Mustache templates for Haskell

Copyright | © 2016–2017 Stack Builders
License | BSD 3 clause
Maintainer | Mark Karpov <markkarpov@openmailbox.org>
Stability | experimental
Portability | portable
Safe Haskell | None
Language | Haskell2010

Text.Microstache.Compile

Description

Mustache `Template` creation from file or a `Text` value. You don't usually need to import the module, because Text.Microstache re-exports everything you may need, import that module instead.

Synopsis

- compileMustacheDir :: PName -> FilePath -> IO Template
- getMustacheFilesInDir :: FilePath -> IO [FilePath]
- compileMustacheFile :: FilePath -> IO Template
- compileMustacheText :: PName -> Text -> Either ParseError Template

# Documentation

compileMustacheDir #

Arguments

:: PName | Which template to select after compiling
-> FilePath | Directory with templates
-> IO Template | The resulting template

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

The action can throw the same exceptions as `getDirectoryContents`, and `readFile`.

getMustacheFilesInDir #

Arguments

:: FilePath | Directory with templates
-> IO [FilePath] |

Return a list of templates found in given directory. The returned paths are absolute.

compileMustacheFile #

Arguments

:: FilePath | Location of the file
-> IO Template |

Compile single Mustache template and select it.

The action can throw the same exceptions as `readFile`.

compileMustacheText #

Arguments

:: PName | How to name the template?
-> Text | The template to compile
-> Either ParseError Template | The result

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