Skip to content
Myr

Merge branch '2.9-maintenance'

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parents 352334c, 8ce8fd3 · Browse files · 3 files+34 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+34 added−1 removed

  • tests:+25 added−0 removed
  • other:+9 added−1 removed

3 files+34 added−1 removed

modified:jinja2/compiler.py+1 added-1 removed
1127 unmodified lines
1128 call_frame, macro_ref = self.macro_body(node, frame)1129 self.writeline('caller = ')1130 self.macro_def(macro_ref, call_frame)1131 self.start_write(frame, node)1132 self.visit_Call(node.call, call_frame, forward_caller=True)1132 self.visit_Call(node.call, frame, forward_caller=True)1133 self.end_write(frame)11341135 def visit_FilterBlock(self, node, frame):1136 filter_frame = frame.inner()
483 unmodified lines
modified:tests/test_regression.py+25 added
385 unmodified lines
386 'child.html': '{% extends "base.html" %}{% set var = 42 %}',387 }))388 t = env.get_template('child.html')389 assert t.render() == '42'390391 def test_caller_scoping(self, env):392 t = env.from_string('''393 {% macro detail(icon, value) -%}394 {% if value -%}395 <p><span class="fa fa-fw fa-{{ icon }}"></span>396 {%- if caller is undefined -%}397 {{ value }}398 {%- else -%}399 {{ caller(value, *varargs) }}400 {%- endif -%}</p>401 {%- endif %}402 {%- endmacro %}403404405 {% macro link_detail(icon, value, href) -%}406 {% call(value, href) detail(icon, value, href) -%}407 <a href="{{ href }}">{{ value }}</a>408 {%- endcall %}409 {%- endmacro %}410 ''')411412 assert t.module.link_detail('circle', 'Index', '/') == (413 '<p><span class="fa fa-fw fa-circle">'414 '</span><a href="/">Index</a></p>')
modified:CHANGES+8 added
1Jinja2 Changelog2================34Version 2.9.15-------------6(bugfix release, released on January 7th 2017)78- Resolved a regression with call block scoping for macros. Nested caller9 blocks that used the same identifiers as outer macros could refer to the10 wrong variable incorrectly.1112Version 2.913-----------14(codename Derivation, released on January 7th 2017)15
424 unmodified lines