Copyright | (c) Justus Adam, 2015 |
---|---|
License | LGPL-3 |
Maintainer | dev@justus.science |
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
- 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]
- getFile :: [FilePath] -> FilePath -> EitherT ParseError IO Text
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 TemplateChache
getPartials :: STree -> [FilePath] Source
Find the names of all included partials in a mustache STree.
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 ParseError
s to be compatible with the internal Either Monad of
compileTemplateWithCache
.