diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2015-02-19 23:20:27 +0100 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2015-02-20 22:28:24 +0100 |
| commit | e4e140c49b1bd3dc8ae11900a0089ec908483cf0 (patch) | |
| tree | 7cdaf69e99ea9cb63daf9543b1df1bbbeea587f5 /django/template/base.py | |
| parent | 88e6fbb2e341657cb5365b9b78fb44e3c7065d2d (diff) | |
[1.8.x] Removed a non-obvious side-effect of assigning Context.template.
Explicit is better than implicit.
Backport of 51b606f from master
Diffstat (limited to 'django/template/base.py')
| -rw-r--r-- | django/template/base.py | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/django/template/base.py b/django/template/base.py index 76f77fc793..0c57050313 100644 --- a/django/template/base.py +++ b/django/template/base.py @@ -202,19 +202,15 @@ class Template(object): def render(self, context): "Display stage -- can be called many times" - # Set context.template to the original template -- as opposed to - # extended or included templates -- during rendering. This may be - # used for accessing context.template.engine. - toplevel_render = context.template is None - if toplevel_render: - context.template = self context.render_context.push() try: - return self._render(context) + if context.template is None: + with context.bind_template(self): + return self._render(context) + else: + return self._render(context) finally: context.render_context.pop() - if toplevel_render: - context.template = None class Token(object): |
