mustache-0.3.1.0: A mustache template parser library.

Copyright(c) Justus Adam, 2015
LicenseLGPL-3
Maintainerdev@justus.science
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone
LanguageHaskell2010

Text.Mustache.Compile

Description

 

Synopsis

Documentation

automaticCompile :: [FilePath] -> FilePath -> IO (Either ParseError Template) Source

Compiles a mustache template provided by name including the mentioned partials.

The same can be done manually using getFile, mustacheParser and getPartials.

This function also ensures each partial is only compiled once even though it may be included by other partials including itself.

A reference to the included template will be found in each including templates partials section.

localAutomaticCompile :: FilePath -> IO (Either ParseError Template) Source

Compile the template with the search space set to only the current directory

type TemplateCache = HashMap String Template Source

A collection of templates with quick access via their hashed names

compileTemplateWithCache :: [FilePath] -> TemplateCache -> FilePath -> IO (Either ParseError Template) Source

Compile a mustache template providing a list of precompiled templates that do not have to be recompiled.

compileTemplate :: String -> Text -> Either ParseError Template Source

Compiles a Template directly from Text without checking for missing partials. the result will be a Template with an empty partials cache.

cacheFromList :: [Template] -> TemplateCache Source

Flatten a list of Templates into a single TemplateChache

getPartials :: AST -> [FilePath] Source

Find the names of all included partials in a mustache AST.

Same as join . fmap getPartials'

getFile :: [FilePath] -> FilePath -> EitherT ParseError IO Text Source

getFile searchSpace file iteratively searches all directories in searchSpace for a file returning it if found or raising an error if none of the directories contain the file.

This trows ParseErrors to be compatible with the internal Either Monad of compileTemplateWithCache.