Skip to content

expressions

Render template expressions.

Functions

render_bool_expression

render_bool_expression(
    expression: Union[str, bool],
    context: Optional[MutableMapping] = None,
) -> bool

Render a template expression and convert the result to a boolean.

Any string expression that is not a template string is wrapped in an {% if ... %} block.

PARAMETER DESCRIPTION
expression

A string expression, a template string, or a boolean.

TYPE: Union[str, bool]

context

The context used to render a string

TYPE: Optional[MutableMapping] DEFAULT: None

RETURNS DESCRIPTION
bool

True if the boolean is True, or the rendered result is not one of False, false, 0, an empty string.

render_expression

render_expression(
    expression: str,
    context: Optional[MutableMapping] = None,
) -> str

Render a template expression.