Use correct concat function for blocks evaluation (#1702)
This commit is contained in:
commit
a4abbfd753
@ -14,6 +14,8 @@ Unreleased
|
||||
``Template.generate_async``. :pr:`1960`
|
||||
- Avoid leaving async generators unclosed in blocks, includes and extends.
|
||||
:pr:`1960`
|
||||
- The runtime uses the correct ``concat`` function for the current environment
|
||||
when calling block references. :issue:`1701`
|
||||
|
||||
|
||||
Version 3.1.4
|
||||
|
||||
@ -367,7 +367,7 @@ class BlockReference:
|
||||
|
||||
@internalcode
|
||||
async def _async_call(self) -> str:
|
||||
rv = concat(
|
||||
rv = self._context.environment.concat( # type: ignore
|
||||
[x async for x in self._stack[self._depth](self._context)] # type: ignore
|
||||
)
|
||||
|
||||
@ -381,7 +381,9 @@ class BlockReference:
|
||||
if self._context.environment.is_async:
|
||||
return self._async_call() # type: ignore
|
||||
|
||||
rv = concat(self._stack[self._depth](self._context))
|
||||
rv = self._context.environment.concat( # type: ignore
|
||||
self._stack[self._depth](self._context)
|
||||
)
|
||||
|
||||
if self._context.eval_ctx.autoescape:
|
||||
return Markup(rv)
|
||||
|
||||
@ -160,3 +160,13 @@ def test_macro(env):
|
||||
result = t.render()
|
||||
assert result == 2
|
||||
assert isinstance(result, int)
|
||||
|
||||
|
||||
def test_block(env):
|
||||
t = env.from_string(
|
||||
"{% block b %}{% for i in range(1) %}{{ loop.index }}{% endfor %}"
|
||||
"{% endblock %}{{ self.b() }}"
|
||||
)
|
||||
result = t.render()
|
||||
assert result == 11
|
||||
assert isinstance(result, int)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user