How are additional arguments and kwargs handled for the Jinja2 macro? The documentation is not entirely clear.
For example, this is clearly not true:
{% macro example_1(one, two, **kwargs) %} do macro stuff {% endmacro %}
that leads to
jinja2.exceptions.TemplateSyntaxError TemplateSyntaxError: expected token 'name', got '**'
The documentation says:
kwargs
Like varargs, but for keyword arguments. All unused keyword arguments are stored in this special variable.
Unfortunately, any combo of additional keyword arguments is a mistake,
{% macro example_2(one, two) %} do macro stuff {% endmacro %} {{ example_2(one, two, test='test') }} TypeError: macro 'example_2' takes no keyword keyword argument 'test'
I have no examples, and I don't get stuck in the Jinja2 atm source code. Currently, the documentation is not clear to me. Any thoughts appreciated.
macros python jinja2
blueblank Dec 19 '12 at 2:35 2012-12-19 02:35
source share