FWIW (years later!) I've just been caught out by this exact same thing. 

What's even more strange in my mind is this: if you pass a variable into a 
macro, and then include a bit of template from within the macro, then the 
included template has access to the variable.  But if you have a template 
that sets the variable and then includes the exact same bit of template, it 
doesn't have access to the variable. (Well, it might - if you happened to 
refer to the variable in the template then it will be there!)

In other words _common can access x in this scenario:
 
{% macro my_macro(x) %} 
{% include "_common.html" %}
{% endmacro %} 

where my_macro gets called like this

{% set x = "value" %}
{% from "macro.html" import my_macro %}
{{ macro(value) }}

But if I do 

{% set x = "value" %}
{% include "_common.html" %}

_common can't get at x. And it becomes confusing if you try to debug 
because in this scenario

{% set x = "value" %}
{{ x }}
{% include "_common.html" %}

_common has got x! This does seem inconsistent. 

 - L 

-- 
You received this message because you are subscribed to the Google Groups 
"pocoo-libs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pocoo-libs.
For more options, visit https://groups.google.com/d/optout.

Reply via email to