def parse_block_for(ast):\r
target = None\r
iter = None\r
- body = parse(ast['contents'])\r
+ body = ast['contents']\r
else_ = []\r
test = None\r
recursive = False\r
if len(block_parameters) > 1:\r
recursive = block_parameters[-1]['value']['variable'] == 'recursive'\r
\r
+ else_ = _split_contents_at_block(ast['contents'], 'else')\r
+\r
+ if else_ is not None:\r
+ body, _, else_ = else_\r
+ else:\r
+ else_ = []\r
+\r
return nodes.For(\r
- target, iter, body, else_, test, recursive,\r
+ target, iter, parse(body), parse(else_), test, recursive,\r
lineno=lineno_from_parseinfo(ast['parseinfo'])\r
)\r
\r
if block_parameters[-2]['value']['variable'] not in ['with', 'without']:\r
return None\r
\r
- return block_parameters[-2]['value']['variable'] == 'with'
\ No newline at end of file
+ return block_parameters[-2]['value']['variable'] == 'with'\r
+\r
+def _split_contents_at_block(contents, block_name):\r
+ for index, expression in enumerate(contents):\r
+ if 'block' in expression:\r
+ block = parse_block(expression)\r
+\r
+ if expression['block']['name'] == block_name:\r
+ return (contents[:index], block, contents[index + 1:])\r
+\r
+ return None\r
{% include ['special_sidebar.html', 'sidebar.html'] ignore missing %}\r
{% include "sidebar.html" ignore missing %}\r
{% include "sidebar.html" ignore missing with context %}\r
-{% include "sidebar.html" ignore missing without context %}
\ No newline at end of file
+{% include "sidebar.html" ignore missing without context %}\r
+{% for item in seq %}\r
+ {{ item }}\r
+{% else %}\r
+ did not iterate\r
+{% endfor %}
\ No newline at end of file