Browse files

Added to each Context a reference to the Engine.

It's only available during the rendering.
  • Loading branch information...
aaugustin committed Nov 20, 2014
1 parent a2dd086 commit 5b1bb40216ff452e34198345fdad63e2be370d2c
Showing with 13 additions and 3 deletions.
  1. +9 −0 django/template/
  2. +4 −3 django/template/
@@ -150,11 +150,19 @@ def _render(self, context):
def render(self, context):
"Display stage -- can be called many times"
# Set engine attribute here to avoid changing the signature of either
# Context.__init__ or Node.render. The engine is set only on the first
# call to render. Further calls e.g. for includes don't override it.
toplevel_render = context.engine is None
if toplevel_render:
context.engine = self.engine
return self._render(context)
if toplevel_render:
context.engine = None
def compile_string(template_string, origin):
@@ -1236,6 +1244,7 @@ def render(self, context):
'current_app': context.current_app,
'use_l10n': context.use_l10n,
'use_tz': context.use_tz,
'engine': context.engine,
# Copy across the CSRF token, if present, because
# inclusion tags are often used for forms, and we need
@@ -121,11 +121,12 @@ def __eq__(self, other):
class Context(BaseContext):
"A stack container for variable context"
def __init__(self, dict_=None, autoescape=True, current_app=None,
use_l10n=None, use_tz=None):
use_l10n=None, use_tz=None, engine=None):
self.autoescape = autoescape
self.current_app = current_app
self.use_l10n = use_l10n
self.use_tz = use_tz
self.engine = engine
self.render_context = RenderContext()
super(Context, self).__init__(dict_)
@@ -186,9 +187,9 @@ class RequestContext(Context):
using the "processors" keyword argument.
def __init__(self, request, dict_=None, processors=None, current_app=None,
use_l10n=None, use_tz=None):
use_l10n=None, use_tz=None, engine=None):
Context.__init__(self, dict_, current_app=current_app,
use_l10n=use_l10n, use_tz=use_tz)
use_l10n=use_l10n, use_tz=use_tz, engine=engine)
if processors is None:
processors = ()

0 comments on commit 5b1bb40

Please sign in to comment.