From: Kevin Date: Sun, 10 May 2020 19:52:07 +0000 (-0400) Subject: Mark with targets as parameters X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=90f036a9345915e4be3456da3ced8a209abbe5d0;p=thirdparty%2Fjinja.git Mark with targets as parameters This fixes a bug where the targets of a `{% with %}` block would not be marked as a parameter. This is because they were not being marked at all as a variable which results in an invalid AST. For reference counting purposes, this must also be marked specifically as a parameter variable instead of as a stored variable to ensure it does not leak out of the block. --- diff --git a/new_parser.py b/new_parser.py index 10d15cdc..b42a7f00 100644 --- a/new_parser.py +++ b/new_parser.py @@ -197,7 +197,7 @@ def parse_block_with(ast): if 'key' not in parameter: raise - targets.append(parameter['key']) + targets.append(nodes.Name(parameter['key'], 'param')) values.append(parse_variable(parameter['value'])) with_node.targets = targets diff --git a/test_template.jinja b/test_template.jinja index 7a4f85aa..3cefad88 100644 --- a/test_template.jinja +++ b/test_template.jinja @@ -1,8 +1,6 @@ {% from 'forms.html' import input as input_field, textarea %} {{ dict_var['single']["double"].dot |test("first" ,2_000, named=3.14)|filter | lastFilter}} -{%with key=val %} -test {{var}} -{%endwith%} +{% with a='', b=a.attribute %}...{% endwith %} {% for item in dict_var.values() %}
  • {% block loop_item %}{{ item }}{% endblock %}
  • {% endfor %}