-
Notifications
You must be signed in to change notification settings - Fork 637
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support spread operator in macro/function arguments #1269
Comments
Personally, I'd love a feature like a spread option, but perhaps in a more compatible way with Jinja.
And these will render identical. However, as far as I know, this is undocumented behavior (in templates). |
I think it would need to also support JS style spread syntax even if the Python compatible syntax were supported because otherwise it would not be intuitive for people using just JS. |
This would be so helpful for my usage - I frequently want to merge an object of params on to an object of defaults. I can do merging with a custom filter, but it would be lovely to be able to do it natively like this: {% set defaultOptions = {
quantity: 5,
price: "£4.5"
} %}
{% set options = {...defaultOptions, params} %} |
I'm trying to dynamically pass in arguments to a macro without knowing either what the argument names are or how many arguments I may be getting. In ES6, the way to do this is to create an array and use the spread syntax. I'd like Nunjucks to support something similar, so I can do the following:
And have it be the same as
The text was updated successfully, but these errors were encountered: