When using object or array literals in templates, if I put a comma after the last item I get a Template render error with a message unexpected token: ] for arrays and unexpected token: } for objects.
All of the examples below trigger these errors for me
{% set obj = { key: "value", anotherKey: "anotherValue", } %}
{% set obj = {
key: "value",
anotherKey: "anotherValue",
} %}
{% set arr = [ "value", "anotherValue", ] %}
{% set arr = [
"value",
"anotherValue",
] %}
Well, that's how it works. Trailing commas are not allowed. As far as I know, same goes for original Jinja2
I think this is valid. It appears that Jinja2 does allow trailing commas in the {% set %} tag, and it is also valid javascript since ECMAScript 5 for objects, earlier for arrays (IE 8 threw a syntax error, which is why many linters did not allow it).
did anyone make progress on this? Happy to try and help out with a PR, its something that trips people up a lot when we're teaching them Nunjucks
Most helpful comment
I think this is valid. It appears that Jinja2 does allow trailing commas in the
{% set %}tag, and it is also valid javascript since ECMAScript 5 for objects, earlier for arrays (IE 8 threw a syntax error, which is why many linters did not allow it).