1
0
mirror of https://github.com/django/django.git synced 2025-10-23 21:59:11 +00:00

Fixed #25469 -- Added autoescape option to DjangoTemplates backend.

Thanks Aymeric for the initial patch and Carl for review.
This commit is contained in:
Aaron Elliot Ross
2015-11-08 10:06:07 +01:00
committed by Tim Graham
parent a8f05f405f
commit 19a5f6da32
7 changed files with 60 additions and 9 deletions

View File

@@ -1,5 +1,6 @@
from template_tests.test_response import test_processor_name
from django.template import EngineHandler
from django.template.backends.django import DjangoTemplates
from django.template.library import InvalidTemplateLibrary
from django.test import RequestFactory, override_settings
@@ -108,3 +109,24 @@ class DjangoTemplatesTests(TemplateStringsTests):
'template_backends.apps.good.templatetags.good_tags',
]
)
def test_autoescape_off(self):
templates = [{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'OPTIONS': {'autoescape': False},
}]
engines = EngineHandler(templates=templates)
self.assertEqual(
engines['django'].from_string('Hello, {{ name }}').render({'name': 'Bob & Jim'}),
'Hello, Bob & Jim'
)
def test_autoescape_default(self):
templates = [{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
}]
engines = EngineHandler(templates=templates)
self.assertEqual(
engines['django'].from_string('Hello, {{ name }}').render({'name': 'Bob & Jim'}),
'Hello, Bob & Jim'
)