minijinja::functions

Function namespace

Source
pub fn namespace(defaults: Option<Value>) -> Result<Value, Error>
Expand description

Creates a new container that allows attribute assignment using the {% set %} tag.

{% set ns = namespace() %}
{% set ns.foo = 'bar' %}

The main purpose of this is to allow carrying a value from within a loop body to an outer scope. Initial values can be provided as a dict, as keyword arguments, or both (same behavior as dict).