Skip to content

environment

Tools and classes for managing the Jinja2 rendering environment.

Classes

InheritanceLoader

InheritanceLoader(inheritance_map: InheritanceMap)

Bases: BaseLoader

Load templates from inherited templates of the same name.

Functions

get_source
get_source(
    environment: Environment, template: str
) -> tuple[str, str | None, Callable[[], bool] | None]

Load the template.

SuperUndefined

Bases: Undefined

Let calls to super() work ok.

Functions

__call__
__call__() -> str

If the undefined is called (like super()) it outputs an empty string.

__getattr__
__getattr__(name: str) -> Any

Override the superclass’ getattr method to handle the jinja_pass_arg attribute.

Functions

load_environment

load_environment(
    template_map: Optional[InheritanceMap] = None,
    extensions: Optional[list] = None,
) -> Environment

Load the Jinja2 template environment.

PARAMETER DESCRIPTION
template_map

The template inheritance used to load the templates

TYPE: Optional[InheritanceMap] DEFAULT: None

extensions

A list of Jinja extensions to load into the environment

TYPE: Optional[list] DEFAULT: None

RETURNS DESCRIPTION
Environment

The Jinja environment