From f437fa3f8d904ea9798ca788eadab120998c23f8 Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Sun, 13 Apr 2008 23:50:11 +0200 Subject: [PATCH] hopefully fixed `Template` --HG-- branch : trunk --- jinja2/environment.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/jinja2/environment.py b/jinja2/environment.py index dff1f13..9d2371d 100644 --- a/jinja2/environment.py +++ b/jinja2/environment.py @@ -148,10 +148,8 @@ class Environment(object): class Template(object): """Represents a template.""" - def __init__(self, environment, code): - namespace = { - 'environment': environment - } + def __init__(self, environment, code, globals): + namespace = {'environment': environment} exec code in namespace self.environment = environment self.name = namespace['filename'] @@ -167,15 +165,16 @@ class Template(object): def generate(self, *args, **kwargs): # assemble the context + local_context = dict(*args, **kwargs) context = self.globals.copy() - context.update(*args, **kwargs) + context.update(local_context) # if the environment is using the optimizer locals may never # override globals as optimizations might have happened # depending on values of certain globals. This assertion goes # away if the python interpreter is started with -O if __debug__ and self.environment.optimized: - overrides = set(context) & set(self.globals) + overrides = set(local_context) & set(self.globals) if overrides: plural = len(overrides) != 1 and 's' or '' raise AssertionError('the per template variable%s %s ' -- 2.26.2