From: Kevin Date: Sun, 10 May 2020 16:16:16 +0000 (-0400) Subject: Properly support recursive in for loops X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f524b56a4221e2ee11c33f396387601f8c29e010;p=thirdparty%2Fjinja.git Properly support recursive in for loops This adds an example to the test file that is being used to verify that the generated ASTs are comparable. --- diff --git a/new_parser.py b/new_parser.py index 29e38885..e491d0f6 100644 --- a/new_parser.py +++ b/new_parser.py @@ -61,6 +61,9 @@ def parse_block_for(ast): target = parse_variable(block_parameters[0]['value'], variable_context='store') iter = parse_variable(block_parameters[2]['value']) + if len(block_parameters) > 3: + recursive = block_parameters[-1]['value']['variable'] == 'recursive' + return nodes.For( target, iter, body, else_, test, recursive, lineno=lineno_from_parseinfo(ast['parseinfo']) diff --git a/test_template.jinja b/test_template.jinja index b67be129..7a4f85aa 100644 --- a/test_template.jinja +++ b/test_template.jinja @@ -43,4 +43,12 @@ across lines #} {% set reply | wordwrap %} You wrote: {{ message }} -{% endset %} \ No newline at end of file +{% endset %} + \ No newline at end of file