Template cache, {% extends %} and globals - design issue? #295

miracle2k opened this Issue Jan 30, 2014 · 1 comment


None yet
2 participants

Say I have this template with an extends call:


{% extends 'base.html' %}

I load it:

jinja2_env.get_template('foo.html', globals=my_globals}

This causes two calls to Environment._load_template: First, for foo.html, the for base.html.

Environment._load_template caches both templates.

The crucial point is that for the second call, the "globals" parameter to Environment._load_template is missing my_globals.

If I now attempt to load the base template directly:

jinja2_env.get_template('base.html', globals=my_globals}

The cache will be used, and my globals will not be available.

Using 2.7.2


mitsuhiko commented Jun 6, 2014

Yes. This is currently the case. This is related to the general problems with scoping in Jinja2 that need to be tackled. Unfortunately that is a very big change and I am not sure how to fix this without spending a lot of time on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment