Copyright | Copyright (C) 2009-2024 John MacFarlane |
---|---|
License | GNU GPL, version 2 or above |
Maintainer | John MacFarlane <jgm@berkeley.edu> |
Stability | alpha |
Portability | portable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Utility functions for working with pandoc templates.
WithDefaultPartials
and WithPartials
are Monad wrappers. Wrapping
these around an instance of PandocMonad
gives different instances of
TemplateMonad
, with different search behaviors when retrieving
partials.
To compile a template and limit partial search to pandoc’s data files,
use runWithDefaultPartials (compileTemplate ...)
.
To compile a template and allow partials to be found locally (either on
the file system or via HTTP, in the event that the main template has an
absolute URL), ue runWithPartials (compileTemplate ...)
.
getTemplate
seeks a template locally, or via HTTP if the template has
an absolute URL, falling back to the data files if not found.
Synopsis
- data Template a
- newtype WithDefaultPartials m a = WithDefaultPartials {
- runWithDefaultPartials :: m a
- newtype WithPartials m a = WithPartials {
- runWithPartials :: m a
- compileTemplate :: (TemplateMonad m, TemplateTarget a) => FilePath -> Text -> m (Either String (Template a))
- renderTemplate :: (TemplateTarget a, ToContext a b) => Template a -> b -> Doc a
- getTemplate :: PandocMonad m => FilePath -> m Text
- getDefaultTemplate :: PandocMonad m => Text -> m Text
- compileDefaultTemplate :: PandocMonad m => Text -> m (Template Text)
Documentation
A template.
Instances
newtype WithDefaultPartials m a Source #
Wrap a Monad in this if you want partials to be taken only from the default data files.
Instances
newtype WithPartials m a Source #
Wrap a Monad in this if you want partials to be looked for locally (or, when the main template is at a URL, via HTTP), falling back to default data files.
WithPartials | |
|
Instances
Applicative m => Applicative (WithPartials m) Source # | |
Defined in Text.Pandoc.Templates pure :: a -> WithPartials m a # (<*>) :: WithPartials m (a -> b) -> WithPartials m a -> WithPartials m b # liftA2 :: (a -> b -> c) -> WithPartials m a -> WithPartials m b -> WithPartials m c # (*>) :: WithPartials m a -> WithPartials m b -> WithPartials m b # (<*) :: WithPartials m a -> WithPartials m b -> WithPartials m a # | |
Functor m => Functor (WithPartials m) Source # | |
Defined in Text.Pandoc.Templates fmap :: (a -> b) -> WithPartials m a -> WithPartials m b # (<$) :: a -> WithPartials m b -> WithPartials m a # | |
Monad m => Monad (WithPartials m) Source # | |
Defined in Text.Pandoc.Templates (>>=) :: WithPartials m a -> (a -> WithPartials m b) -> WithPartials m b # (>>) :: WithPartials m a -> WithPartials m b -> WithPartials m b # return :: a -> WithPartials m a # | |
PandocMonad m => TemplateMonad (WithPartials m) Source # | |
Defined in Text.Pandoc.Templates getPartial :: FilePath -> WithPartials m Text # |
compileTemplate :: (TemplateMonad m, TemplateTarget a) => FilePath -> Text -> m (Either String (Template a)) #
Compile a template. The FilePath parameter is used to determine a default path and extension for partials and may be left empty if partials are not used.
renderTemplate :: (TemplateTarget a, ToContext a b) => Template a -> b -> Doc a #
Render a compiled template in a "context" which provides values for the template's variables.
getTemplate :: PandocMonad m => FilePath -> m Text Source #
Retrieve text for a template.
:: PandocMonad m | |
=> Text | Name of writer |
-> m Text |
Get default template for the specified writer.
compileDefaultTemplate :: PandocMonad m => Text -> m (Template Text) Source #
Get and compile default template for the specified writer. Raise an error on compilation failure.