Skip to content
Permalink
Browse files

Resolved bad code generation on toplevel ifs

This fixes #651
  • Loading branch information...
mitsuhiko committed Jan 9, 2017
1 parent ef71801 commit e73c574c2130ac71857b3beb5ebf03bf03de01d7
Showing with 8 additions and 2 deletions.
  1. +3 −0 CHANGES
  2. +1 −2 jinja2/compiler.py
  3. +4 −0 tests/test_regression.py
@@ -9,6 +9,9 @@ Version 2.9.4
- Increment the bytecode cache version which was not done due to an
oversight before.
- Corrected bad code generation and scoping for filtered loops. (#649)
- Resolved an issue where top-level output silencing after known extend
blocks could generate invalid code when blocks where contained in if
statements. (#651)

Version 2.9.3
-------------
@@ -367,8 +367,7 @@ def blockvisit(self, nodes, frame):
is no buffer a dummy ``if 0: yield None`` is written automatically.
"""
try:
if not nodes:
self.writeline('pass')
self.writeline('pass')
for node in nodes:
self.visit(node, frame)
except CompilerExit:
@@ -479,3 +479,7 @@ def test_recursive_loop_filter(self, env):
'<url><loc>/bar</loc></url>',
'</urlset>',
]

def test_empty_if(self, env):
t = env.from_string('{% if foo %}{% else %}42{% endif %}')
assert t.render(foo=False) == '42'

0 comments on commit e73c574

Please sign in to comment.
You can’t perform that action at this time.