exhibition.filters.jinja2 module

Jinja2 template filter

To use, add the following to your configuration file:

filter: exhibition.filters.jinja2
class exhibition.filters.jinja2.JinjaFilter(extra_filters=None)[source]

Bases: BaseFilter

This is the actual content filter called by exhibition.main.Node on appropriate nodes.

Parameters
  • node – The node being rendered

  • content – The content of the node, stripped of any YAML frontmatter

extra_filters should be a dict. The keys are the name of the filter and the values are the template filters

add_template_filters(env)[source]

Add template filters to current Environment

content_filter()[source]

Bring everything together and render the template

extensions = (<class 'exhibition.filters.jinja2.RaiseError'>, <class 'exhibition.filters.jinja2.Mark'>)
get_context_data()[source]

Returns context data that is used for rendering the template

get_environment()[source]

Get Jinja environment

Sets up template loader and extensions

prepare_content()[source]

Prepares content by adding {% extends %} and a default block, if either are specified

template_loader_class

alias of FileSystemLoader

class exhibition.filters.jinja2.Mark(environment: Environment)[source]

Bases: Extension

Marks a section for use later:

{% mark intro %}
<p>My Intro</p>
{% endmark %}

<p>Some more text</p>

This can then be referenced via Node.marks.

identifier: ClassVar[str] = 'exhibition.filters.jinja2.Mark'
parse(parser)[source]

If any of the tags matched this method is called with the parser as first argument. The token the parser stream is pointing at is the name token that matched. This method has to return one or a list of multiple nodes.

tags: Set[str] = {'mark'}

if this extension parses this is the list of tags it’s listening to.

class exhibition.filters.jinja2.RaiseError(environment: Environment)[source]

Bases: Extension

Raise an exception during template rendering:

{% raise "This is an error" %}
identifier: ClassVar[str] = 'exhibition.filters.jinja2.RaiseError'
parse(parser)[source]

If any of the tags matched this method is called with the parser as first argument. The token the parser stream is pointing at is the name token that matched. This method has to return one or a list of multiple nodes.

tags: Set[str] = {'raise'}

if this extension parses this is the list of tags it’s listening to.

exhibition.filters.jinja2.markdown(ctx, text)[source]
exhibition.filters.jinja2.metareject(nodes, key)[source]
exhibition.filters.jinja2.metaselect(nodes, key)[source]
exhibition.filters.jinja2.metasort(nodes, key=None, reverse=False)[source]

Sorts a list of nodes based on keys found in their meta objects

exhibition.filters.jinja2.pandoc(ctx, text, fmt=None)[source]

Use Pandoc to convert from one format to another. Takes source format as an optional argument.

Uses the same pandoc_config meta key as exhibition.filters.pandoc