You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently when you define a macro, it can be called with positional arguments and named arguments. In normal python you can disable the use of positional arguments by using a asterisk, forcing any further arguments to be named. The proposal is to support the same functionality in Jinja.
For example, python allows:
deffoo(bar='bar', *, a=1, b):
...
The proposal is to support:
{%macrofoo(bar='bar', *, a=1, b) %}
...
{%endmacro%}
Commonly in python, this is something like *args and not just a bare *. However Jinja already has the special variable varargs. While support for *args (or any other custom name) could be supported, I figure a bare * would be a simpler change (and forward compatible if *args were to be supported).
Why?
One reason is when you don't want to support positional arguments. For example you might not want to make API guarantees that the position of arguments will remain unchanged.
Another is when you don't want to have to put default arguments at the end. It might make the code more readable to keep related arguments together, instead of having to put the ones without defaults at the front, and the ones with defaults at the end.
The text was updated successfully, but these errors were encountered:
Currently when you define a macro, it can be called with positional arguments and named arguments. In normal python you can disable the use of positional arguments by using a asterisk, forcing any further arguments to be named. The proposal is to support the same functionality in Jinja.
For example, python allows:
The proposal is to support:
Commonly in python, this is something like
*args
and not just a bare*
. However Jinja already has the special variablevarargs
. While support for*args
(or any other custom name) could be supported, I figure a bare*
would be a simpler change (and forward compatible if*args
were to be supported).Why?
One reason is when you don't want to support positional arguments. For example you might not want to make API guarantees that the position of arguments will remain unchanged.
Another is when you don't want to have to put default arguments at the end. It might make the code more readable to keep related arguments together, instead of having to put the ones without defaults at the front, and the ones with defaults at the end.
The text was updated successfully, but these errors were encountered: