1
0
mirror of https://github.com/django/django.git synced 2025-11-07 07:15:35 +00:00

Fixed #12847 -- Added name parameter to simple_tag, assignment_tag and inclusion_tag helpers. Thanks, vladmos.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16373 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Jannis Leidel
2011-06-11 16:05:28 +00:00
parent 4970ef07c2
commit d27f909d2e
5 changed files with 33 additions and 8 deletions

View File

@@ -114,3 +114,9 @@ def assignment_params_and_context(context, arg):
"""Expected assignment_params_and_context __doc__"""
return "assignment_params_and_context - Expected result (context value: %s): %s" % (context['value'], arg)
assignment_params_and_context.anything = "Expected assignment_params_and_context __dict__"
register.simple_tag(lambda x: x - 1, name='minusone')
@register.simple_tag(name='minustwo')
def minustwo_overridden_name(value):
return value - 2

View File

@@ -1385,6 +1385,11 @@ class Templates(unittest.TestCase):
'templatetag11': ('{% templatetag opencomment %}', {}, '{#'),
'templatetag12': ('{% templatetag closecomment %}', {}, '#}'),
# Simple tags with customized names
'simpletag-renamed01': ('{% load custom %}{% minusone 7 %}', {}, '6'),
'simpletag-renamed02': ('{% load custom %}{% minustwo 7 %}', {}, '5'),
'simpletag-renamed03': ('{% load custom %}{% minustwo_overridden_name 7 %}', {}, template.TemplateSyntaxError),
### WIDTHRATIO TAG ########################################################
'widthratio01': ('{% widthratio a b 0 %}', {'a':50,'b':100}, '0'),
'widthratio02': ('{% widthratio a b 100 %}', {'a':0,'b':0}, ''),