mustache-2.4.0: A mustache template parser library.
Copyright(c) Justus Adam 2015
LicenseBSD3
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 TemplateCache

getPartials :: STree -> [FilePath] Source #

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

Same as join . fmap getPartials'

mustache :: QuasiQuoter Source #

Compile a mustache Template at compile time. Usage:

{-# LANGUAGE QuasiQuotes #-}
import Text.Mustache.Compile (mustache)

foo :: Template
foo = [mustache|This is my inline {{ template }} created at compile time|]

Partials are not supported in the QuasiQuoter

embedTemplate :: [FilePath] -> FilePath -> Q Exp Source #

Compile a mustache Template at compile time providing a search space for any partials. Usage:

{-# LANGUAGE TemplateHaskell #-}
import Text.Mustache.Compile (embedTemplate)

foo :: Template
foo = $(embedTemplate ["dir", "dir/partials"] "file.mustache")

embedSingleTemplate :: FilePath -> Q Exp Source #

Compile a mustache Template at compile time. Usage:

{-# LANGUAGE TemplateHaskell #-}
import Text.Mustache.Compile (embedSingleTemplate)

foo :: Template
foo = $(embedSingleTemplate "dir/file.mustache")

Partials are not supported in embedSingleTemplate