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

Description

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

Synopsis

Documentation

compileMustacheDir Source #

Arguments

:: MonadIO m 
=> PName

Which template to select after compiling

-> FilePath

Directory with templates

-> m Template

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.

Note that each template/partial will get an identifier which consists of the name of corresponding template file with extension .mustache dropped. This is important for e.g. selecting active template after loading (the first argument).

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

compileMustacheDir = complieMustacheDir' isMustacheFile

compileMustacheDir' Source #

Arguments

:: MonadIO m 
=> (FilePath -> Bool)

Template selection predicate

-> PName

Which template to select after compiling

-> FilePath

Directory with templates

-> m Template

The resulting template

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

Since: 1.2.0

getMustacheFilesInDir Source #

Arguments

:: MonadIO m 
=> FilePath

Directory with templates

-> m [FilePath] 

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

Since: 0.2.2

getMustacheFilesInDir' Source #

Arguments

:: MonadIO m 
=> (FilePath -> Bool)

Mustache file selection predicate

-> FilePath

Directory with templates

-> m [FilePath] 

Return a list of templates that satisfy a predicate in a given directory. The returned paths are absolute.

Since: 1.2.0

isMustacheFile :: FilePath -> Bool Source #

The default Mustache file predicate.

Since: 1.2.0

compileMustacheFile Source #

Arguments

:: MonadIO m 
=> FilePath

Location of the file

-> m Template 

Compile a Mustache template and select it.

The action can throw MustacheParserException and the same exceptions as readFile.

compileMustacheText Source #

Arguments

:: PName

How to name the template?

-> Text

The template to compile

-> Either (ParseErrorBundle Text Void) Template

The result

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