1
0
mirror of https://github.com/django/django.git synced 2025-10-25 06:36:07 +00:00

Fixed #11989 -- Allow passing a Template instance to inclusion_tag. Thanks to Jeremy Dunck and tcoenen.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16374 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Jannis Leidel
2011-06-11 16:22:45 +00:00
parent d27f909d2e
commit 0ebaf10258
4 changed files with 61 additions and 1 deletions

View File

@@ -73,6 +73,24 @@ class CustomTagTests(TestCase):
t = template.Template('{% load custom %}{% inclusion_params_and_context 37 %}')
self.assertEqual(t.render(c), u'inclusion_params_and_context - Expected result (context value: 42): 37\n')
def test_inclusion_tags_from_template(self):
c = template.Context({'value': 42})
t = template.Template('{% load custom %}{% inclusion_no_params_from_template %}')
self.assertEqual(t.render(c), u'inclusion_no_params_from_template - Expected result\n')
t = template.Template('{% load custom %}{% inclusion_one_param_from_template 37 %}')
self.assertEqual(t.render(c), u'inclusion_one_param_from_template - Expected result: 37\n')
t = template.Template('{% load custom %}{% inclusion_explicit_no_context_from_template 37 %}')
self.assertEqual(t.render(c), u'inclusion_explicit_no_context_from_template - Expected result: 37\n')
t = template.Template('{% load custom %}{% inclusion_no_params_with_context_from_template %}')
self.assertEqual(t.render(c), u'inclusion_no_params_with_context_from_template - Expected result (context value: 42)\n')
t = template.Template('{% load custom %}{% inclusion_params_and_context_from_template 37 %}')
self.assertEqual(t.render(c), u'inclusion_params_and_context_from_template - Expected result (context value: 42): 37\n')
def test_inclusion_tag_registration(self):
# Test that the decorators preserve the decorated function's docstring, name and attributes.
self.verify_tag(custom.inclusion_no_params, 'inclusion_no_params')