Skip to content

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

Description

@miracle2k

Say I have this template with an extends call:

foo.html:

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

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions