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:
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user