From: Armin Ronacher Date: Sun, 13 Apr 2008 21:50:11 +0000 (+0200) Subject: hopefully fixed `Template` X-Git-Tag: 2.0rc1~171 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=f437fa3f8d904ea9798ca788eadab120998c23f8;p=jinja2.git hopefully fixed `Template` --HG-- branch : trunk --- 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 '