Skip to content

Commit

Permalink
Merge branch '2.9-maintenance'
Browse files Browse the repository at this point in the history
  • Loading branch information
mitsuhiko committed Jan 8, 2017
2 parents c1b4469 + 07c33a5 commit 6b8a14a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ Version 2.9.2
common case that gets copy pasted around. To not completely break backwards
compatibility with the most common cases it's now possible to provide an
explicit keyword argument for caller if it's given an explicit default.
(#642)
- Restored the use of blocks in macros to the extend that was possible
before. On Python 3 it would render a generator repr instead of
the block contents. (#645)

Version 2.9.1
-------------
Expand Down
3 changes: 2 additions & 1 deletion jinja2/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,8 @@ def visit_Block(self, node, frame):
context = node.scoped and (
'context.derived(%s)' % self.dump_local_context(frame)) or 'context'

if supports_yield_from and not self.environment.is_async:
if supports_yield_from and not self.environment.is_async and \
frame.buffer is None:
self.writeline('yield from context.blocks[%r][0](%s)' % (
node.name, context), node)
else:
Expand Down
5 changes: 5 additions & 0 deletions tests/test_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,3 +442,8 @@ def test_double_caller_no_default(self, env):
t.module.x(None, caller=lambda: 42)
assert exc_info.match(r'\'x\' was invoked with two values for the '
r'special caller argument')

def test_macro_blocks(self, env):
t = env.from_string('{% macro x() %}{% block foo %}x{% '
'endblock %}{% endmacro %}{{ x() }}')
assert t.render() == 'x'

0 comments on commit 6b8a14a

Please sign in to comment.