pandoc-2.5: Conversion between markup formats

Copyright | Copyright (C) 2009-2018 John MacFarlane
License | GNU GPL, version 2 or above
Maintainer | John MacFarlane <jgm@berkeley.edu>
Stability | alpha
Portability | portable
Safe Haskell | None
Language | Haskell2010

Text.Pandoc.Templates

Description

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 Source #

Combines `renderTemplate` and `compileTemplate`.

renderTemplate :: (ToJSON a, TemplateTarget b) => Template -> a -> b Source #

Render a compiled template using `context` to resolve variables.

compileTemplate :: Text -> Either String Template Source #

Compile a template.

varListToJSON :: [(String, String)] -> Value Source #

A convenience function for passing in an association list of string values instead of a JSON `Value`.

data Template Source #

A `Template` is essentially a function that takes a JSON `Value` and produces `Text`.

Instances

Semigroup Template |
Instance details Defined in Text.DocTemplates Methods (<>) :: Template -> Template -> Template Source # sconcat :: NonEmpty Template -> Template Source # stimes :: Integral b => b -> Template -> Template Source #
Monoid Template |
Instance details Defined in Text.DocTemplates Methods mempty :: Template Source # mappend :: Template -> Template -> Template Source # mconcat :: [Template] -> Template Source #

class TemplateTarget a Source #

Minimal complete definition

toTarget

Instances

TemplateTarget String |
Instance details Defined in Text.DocTemplates Methods toTarget :: Text -> String Source #
TemplateTarget ByteString |
Instance details Defined in Text.DocTemplates Methods toTarget :: Text -> ByteString Source #
TemplateTarget Text |
Instance details Defined in Text.DocTemplates Methods toTarget :: Text -> Text Source #
TemplateTarget Html |
Instance details Defined in Text.DocTemplates Methods toTarget :: Text -> Html Source #

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.

getDefaultTemplate Source #

Arguments

:: PandocMonad m |
=> String | Name of writer
-> m String |

Get default template for the specified writer.