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:
BaseFilterThis is the actual content filter called by
exhibition.main.Nodeon appropriate nodes.- Parameters:
node – The node being rendered
content – The content of the node, stripped of any YAML frontmatter
extra_filtersshould be a dict. The keys are the name of the filter and the values are the template filters- extensions = (<class 'exhibition.filters.jinja2.RaiseError'>, <class 'exhibition.filters.jinja2.Mark'>)
- 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:
ExtensionMarks 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: t.ClassVar[str] = 'exhibition.filters.jinja2.Mark'
- parse(parser)[source]
If any of the
tagsmatched 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: t.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:
ExtensionRaise an exception during template rendering:
{% raise "This is an error" %}
- identifier: t.ClassVar[str] = 'exhibition.filters.jinja2.RaiseError'
- parse(parser)[source]
If any of the
tagsmatched 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: t.Set[str] = {'raise'}
if this extension parses this is the list of tags it’s listening to.
- 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_configmeta key asexhibition.filters.pandoc