Copyright | (c) Justus Adam 2015 |
---|---|
License | BSD3 |
Maintainer | dev@justus.science |
Stability | experimental |
Portability | POSIX |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Synopsis
- automaticCompile :: [FilePath] -> FilePath -> IO (Either ParseError Template)
- localAutomaticCompile :: FilePath -> IO (Either ParseError Template)
- type TemplateCache = HashMap String Template
- compileTemplateWithCache :: [FilePath] -> TemplateCache -> FilePath -> IO (Either ParseError Template)
- compileTemplate :: String -> Text -> Either ParseError Template
- cacheFromList :: [Template] -> TemplateCache
- getPartials :: STree -> [FilePath]
- mustache :: QuasiQuoter
- embedTemplate :: [FilePath] -> FilePath -> Q Exp
- embedSingleTemplate :: FilePath -> Q Exp
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 #
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")