Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call block fails to carry scope when outer macro uses {% set %} or keyword argument #1131

Open
albedoa opened this issue Jul 24, 2018 · 0 comments
Labels

Comments

@albedoa
Copy link

albedoa commented Jul 24, 2018

This looks like it might be a remnant of #906, but maybe it's expected behavior. Please let me know if I am missing something. The only addition I've made to the example given in that issue is the keyword argument in the outside() signature:

{% macro inside() %}
  <div>inside: {{ caller() }}</div>
{% endmacro %}

{% macro outside(var = "baz") %}
  <div>outside: {{ var }}</div>

  {% call inside() %}
    {{ var }}
  {% endcall %}
{% endmacro %}

{{ outside("foobar") }}

The output is:

outside: foobar
inside:

I expect the output to be:

outside: foobar
inside: foobar

A demo can be seen here: http://jsfiddle.net/j8Lur5tx/

Edit: I seem to have been wrong about the cause of this behavior. It also happens to variables set in the outer macro block. The following produces the same effect:

{% macro inside() %}
  <div>inside: {{ caller() }}</div>
{% endmacro %}

{% macro outside() %}
  {% set var = "baz" %}

  {% call inside() %}
    {{ var }}
  {% endcall %}
{% endmacro %}

{{ outside() }}
@albedoa albedoa changed the title Call block fails to carry scope when outer macro uses keyword argument Call block fails to carry scope when outer macro uses {% set %} or keyword argument Jul 25, 2018
@fdintino fdintino added the bug label Aug 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants