]> git.ipfire.org Git - thirdparty/jinja.git/commitdiff
Mark with targets as parameters
authorKevin <kevin@kevin-brown.com>
Sun, 10 May 2020 19:52:07 +0000 (15:52 -0400)
committerKevin <kevin@kevin-brown.com>
Sun, 10 May 2020 19:52:07 +0000 (15:52 -0400)
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.

new_parser.py
test_template.jinja

index 10d15cdc038e0ba2a504ba7273e4832f5b45cb0f..b42a7f000ad547a38b5b1806d6efbee13d9784f7 100644 (file)
@@ -197,7 +197,7 @@ def parse_block_with(ast):
         if 'key' not in parameter:\r
             raise\r
 \r
-        targets.append(parameter['key'])\r
+        targets.append(nodes.Name(parameter['key'], 'param'))\r
         values.append(parse_variable(parameter['value']))\r
 \r
     with_node.targets = targets\r
index 7a4f85aa1b933a5740aa1aa4adc4cc20a6b76149..3cefad881a16ca9288acbb8a8759d8d7d068e476 100644 (file)
@@ -1,8 +1,6 @@
 {% from 'forms.html' import input as input_field, textarea %}\r
 {{ dict_var['single']["double"].dot  |test("first" ,2_000, named=3.14)|filter | lastFilter}}\r
-{%with key=val %}\r
-test {{var}}\r
-{%endwith%}\r
+{% with a='', b=a.attribute %}...{% endwith %}\r
 {% for item in dict_var.values() %}\r
     <li>{% block loop_item %}{{ item }}{% endblock %}</li>\r
 {% endfor %}\r