pandoc.template

apply

function pandoc.template.apply(template: pandoc.Template, context: table<string, any>)
  -> pandoc.Doc

Applies a context with variable assignments to a template, returning the rendered template. The context parameter must be a table with variable names as keys and [Doc], string, boolean, or table as values, where the table can be either be a list of the aforementioned types, or a nested context.

compile

function pandoc.template.compile(template: string, templates_path?: string)
  -> pandoc.Template

Compiles a template string into a Template object usable by pandoc.

If the templates_path parameter is specified, should be the file path associated with the template. It is used when checking for partials. Partials will be taken only from the default data files if this parameter is omitted.

An error is raised if compilation fails.

default

function pandoc.template.default(writer?: string)
  -> string

Returns the default template for a given writer as a string. An error if no such template can be found.

get

function pandoc.template.get(filename: string)
  -> string

Retrieve text for a template.

This function first checks the resource paths for a file of this name; if none is found, the templates directory in the user data directory is checked. Returns the content of the file, or throws an error if no file is found.

meta_to_context

function pandoc.template.meta_to_context(meta: table<string, boolean|string|number|pandoc.List|table<number, pandoc.MetaValue>...(+1)>, blocks_writer: fun(blocks: pandoc.Blocks):pandoc.Doc, inlines_writer: fun(inlines: pandoc.Inlines):pandoc.Doc)
  -> table<string, any>

Creates template context from the document’s Meta data, using the given functions to convert [Blocks] and [Inlines] to [Doc] values.