Copyright | Copyright (C) 2009-2019 John MacFarlane |
---|---|
License | GNU GPL, version 2 or above |
Maintainer | John MacFarlane <jgm@berkeley.edu> |
Stability | alpha |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
A simple templating system with variable substitution and conditionals.
Synopsis
- applyTemplate :: (ToJSON a, TemplateTarget b) => Text -> a -> Either String b
- renderTemplate :: (ToJSON a, TemplateTarget b) => Template -> a -> b
- compileTemplate :: Text -> Either String Template
- varListToJSON :: [(String, String)] -> Value
- data Template
- class TemplateTarget a
- renderTemplate' :: (PandocMonad m, ToJSON a, TemplateTarget b) => String -> a -> m b
- getDefaultTemplate :: PandocMonad m => String -> m String
Documentation
applyTemplate :: (ToJSON a, TemplateTarget b) => Text -> a -> Either String b #
Combines renderTemplate
and compileTemplate
.
renderTemplate :: (ToJSON a, TemplateTarget b) => Template -> a -> b #
Render a compiled template using context
to resolve variables.
varListToJSON :: [(String, String)] -> Value #
A convenience function for passing in an association
list of string values instead of a JSON Value
.
class TemplateTarget a #
Instances
TemplateTarget String | |
Defined in Text.DocTemplates | |
TemplateTarget ByteString | |
Defined in Text.DocTemplates toTarget :: Text -> ByteString # | |
TemplateTarget Text | |
Defined in Text.DocTemplates | |
TemplateTarget Html | |
Defined in Text.DocTemplates |
renderTemplate' :: (PandocMonad m, ToJSON a, TemplateTarget b) => String -> a -> m b Source #
Like applyTemplate
, but runs in PandocMonad and
raises an error if compilation fails.
:: PandocMonad m | |
=> String | Name of writer |
-> m String |
Get default template for the specified writer.