Hi Community,

Environment:  I am using jinja2 version 2.7.3 with Python 2.7.5.

I using the Template.make_module() method passing in the `vars=varsbag` and 
`shared=True` options.  (varsbag is an object derived from dict).  I'll 
defer the purpose of varsbag as present, but can elaborate if needed.

I noticed an odd behavior when I have a template file that uses the {% 
include %} directive.  Let's say I have a top-level template file called 
"main.conf".  The top-level file has {% includes 'services.conf' %}.  The 
services.conf file has simply more content; and it uses variables that 
*should* be accessible via the varsbag variable.  However, when I invoke 
make_modules() I get an Undefined error on the variable in use.  If I copy 
the contents of the services.conf file directly into the main.conf 
everything works A-OK.  So it appears that there is a "context" issue when 
including files as I am doing.

I did some research and did some testing.  I found that if I changed my 
services.conf file and restructured to define macro statements; and then 
from main.conf did {% from 'services.conf' import create_service with 
context %} this seems to be A-OK.

>From what I've read, I *thought* the standard {% include 'services.conf' %} 
should perform the effective 'with context' automatically.  But this does 
not seem to be the case; and even attempting {% include 'services.conf' 
with context %} results in the same issue.

QUESTION:  Could someone please confirm/deny the {% include 'services.conf' 
%} SHOULD import the context in the use case of invoking make_module()?

I hope the above makes sense; really appreciate folks help with this.

Thank you!
-- Jeremy

-- 
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