diff --git a/django/template/backends/django.py b/django/template/backends/django.py
index af58f60..897b766 100644
|
a
|
b
|
class DjangoTemplates(BaseEngine):
|
| 23 | 23 | def __init__(self, params): |
| 24 | 24 | params = params.copy() |
| 25 | 25 | options = params.pop('OPTIONS').copy() |
| | 26 | options.setdefault('autoescape', True) |
| 26 | 27 | options.setdefault('debug', settings.DEBUG) |
| 27 | 28 | options.setdefault('file_charset', settings.FILE_CHARSET) |
| 28 | 29 | libraries = options.get('libraries', {}) |
| … |
… |
class Template(object):
|
| 60 | 61 | return self.template.origin |
| 61 | 62 | |
| 62 | 63 | def render(self, context=None, request=None): |
| 63 | | context = make_context(context, request) |
| | 64 | context = make_context(context, request, |
| | 65 | autoescape=self.backend.engine.autoescape) |
| 64 | 66 | try: |
| 65 | 67 | return self.template.render(context) |
| 66 | 68 | except TemplateDoesNotExist as exc: |
diff --git a/django/template/context.py b/django/template/context.py
index 2643e92..1d70f45 100644
|
a
|
b
|
class RequestContext(Context):
|
| 245 | 245 | return new_context |
| 246 | 246 | |
| 247 | 247 | |
| 248 | | def make_context(context, request=None): |
| | 248 | def make_context(context, request=None, **kwargs): |
| 249 | 249 | """ |
| 250 | 250 | Create a suitable Context from a plain dict and optionally an HttpRequest. |
| 251 | 251 | """ |
| 252 | 252 | if request is None: |
| 253 | | context = Context(context) |
| | 253 | context = Context(context, **kwargs) |
| 254 | 254 | else: |
| 255 | 255 | # The following pattern is required to ensure values from |
| 256 | 256 | # context override those from template context processors. |
| 257 | 257 | original_context = context |
| 258 | | context = RequestContext(request) |
| | 258 | context = RequestContext(request, **kwargs) |
| 259 | 259 | if original_context: |
| 260 | 260 | context.push(original_context) |
| 261 | 261 | return context |
diff --git a/django/template/engine.py b/django/template/engine.py
index d439f49..2305b6b 100644
|
a
|
b
|
class Engine(object):
|
| 16 | 16 | 'django.template.loader_tags', |
| 17 | 17 | ] |
| 18 | 18 | |
| 19 | | def __init__(self, dirs=None, app_dirs=False, context_processors=None, |
| 20 | | debug=False, loaders=None, string_if_invalid='', |
| 21 | | file_charset='utf-8', libraries=None, builtins=None): |
| | 19 | def __init__(self, dirs=None, app_dirs=False, autoescape=True, |
| | 20 | context_processors=None, debug=False, loaders=None, |
| | 21 | string_if_invalid='', file_charset='utf-8', |
| | 22 | libraries=None, builtins=None): |
| 22 | 23 | if dirs is None: |
| 23 | 24 | dirs = [] |
| 24 | 25 | if context_processors is None: |
| … |
… |
class Engine(object):
|
| 38 | 39 | |
| 39 | 40 | self.dirs = dirs |
| 40 | 41 | self.app_dirs = app_dirs |
| | 42 | self.autoescape = autoescape |
| 41 | 43 | self.context_processors = context_processors |
| 42 | 44 | self.debug = debug |
| 43 | 45 | self.loaders = loaders |
diff --git a/docs/ref/templates/api.txt b/docs/ref/templates/api.txt
index 570ffbc..796d945 100644
|
a
|
b
|
probably isn't the documentation you're looking for. An instance of the
|
| 48 | 48 | of that backend and any attribute defaults mentioned below are overridden by |
| 49 | 49 | what's passed by :class:`~django.template.backends.django.DjangoTemplates`. |
| 50 | 50 | |
| 51 | | .. class:: Engine(dirs=None, app_dirs=False, context_processors=None, debug=False, loaders=None, string_if_invalid='', file_charset='utf-8', libraries=None, builtins=None) |
| | 51 | .. class:: Engine(dirs=None, app_dirs=False, autocomplete=True, context_processors=None, debug=False, loaders=None, string_if_invalid='', file_charset='utf-8', libraries=None, builtins=None) |
| 52 | 52 | |
| 53 | 53 | When instantiating an ``Engine`` all arguments must be passed as keyword |
| 54 | 54 | arguments: |
| … |
… |
what's passed by :class:`~django.template.backends.django.DjangoTemplates`.
|
| 63 | 63 | |
| 64 | 64 | It defaults to ``False``. |
| 65 | 65 | |
| | 66 | * ``autocomplete`` controls whether HTML autoescaping is enabled. |
| | 67 | |
| | 68 | It default to ``True``. |
| | 69 | |
| | 70 | .. warning:: |
| | 71 | |
| | 72 | Only set it to ``False`` if you're rendering non-HTML templates! |
| | 73 | |
| | 74 | .. versionadded:: 1.10 |
| | 75 | |
| | 76 | The ``autocomplete`` option was added. |
| | 77 | |
| 66 | 78 | * ``context_processors`` is a list of dotted Python paths to callables |
| 67 | 79 | that are used to populate the context when a template is rendered with a |
| 68 | 80 | request. These callables take a request object as their argument and |
diff --git a/docs/topics/templates.txt b/docs/topics/templates.txt
index f0abccc..5da754e 100644
|
a
|
b
|
applications. This generic name was kept for backwards-compatibility.
|
| 295 | 295 | ``DjangoTemplates`` engines accept the following :setting:`OPTIONS |
| 296 | 296 | <TEMPLATES-OPTIONS>`: |
| 297 | 297 | |
| | 298 | * ``'autocomplete'``: a boolean that controls whether HTML autoescaping is |
| | 299 | enabled. |
| | 300 | |
| | 301 | It default to ``True``. |
| | 302 | |
| | 303 | .. warning:: |
| | 304 | |
| | 305 | Only set it to ``False`` if you're rendering non-HTML templates! |
| | 306 | |
| | 307 | .. versionadded:: 1.10 |
| | 308 | |
| | 309 | The ``autocomplete`` option was added. |
| | 310 | |
| 298 | 311 | * ``'context_processors'``: a list of dotted Python paths to callables that |
| 299 | 312 | are used to populate the context when a template is rendered with a request. |
| 300 | 313 | These callables take a request object as their argument and return a |