Ticket #12847: renamed_simple_tags.patch
File renamed_simple_tags.patch, 3.0 KB (added by , 13 years ago) |
---|
-
django/template/base.py
866 866 self.filters[getattr(func, "_decorated_function", func).__name__] = func 867 867 return func 868 868 869 def simple_tag(self, func=None, takes_context=None ):869 def simple_tag(self, func=None, takes_context=None, name=None): 870 870 def dec(func): 871 params, xx, xxx, defaults = getargspec(func)871 params, varargs, kwargs, defaults = getargspec(func) 872 872 if takes_context: 873 873 if params[0] == 'context': 874 874 params = params[1:] … … 887 887 func_args = resolved_vars 888 888 return func(*func_args) 889 889 890 compile_func = partial(generic_tag_compiler, params, defaults, getattr(func, "_decorated_function", func).__name__, SimpleNode) 890 function_name = name or getattr(func, '_decorated_function', func).__name__ 891 compile_func = partial(generic_tag_compiler, params, defaults, function_name, SimpleNode) 891 892 compile_func.__doc__ = func.__doc__ 892 self.tag( getattr(func, "_decorated_function", func).__name__, compile_func)893 self.tag(function_name, compile_func) 893 894 return func 894 895 895 896 if func is None: -
tests/regressiontests/templates/tests.py
1385 1385 'templatetag11': ('{% templatetag opencomment %}', {}, '{#'), 1386 1386 'templatetag12': ('{% templatetag closecomment %}', {}, '#}'), 1387 1387 1388 # Simple tags with customized names 1389 'simpletag-renamed01': ('{% load custom %}{% minusone 7 %}', {}, '6'), 1390 'simpletag-renamed02': ('{% load custom %}{% minustwo 7 %}', {}, '5'), 1391 'simpletag-renamed03': ('{% load custom %}{% minustwo_overridden_name 7 %}', {}, template.TemplateSyntaxError), 1392 1388 1393 ### WIDTHRATIO TAG ######################################################## 1389 1394 'widthratio01': ('{% widthratio a b 0 %}', {'a':50,'b':100}, '0'), 1390 1395 'widthratio02': ('{% widthratio a b 100 %}', {'a':0,'b':0}, ''), -
tests/regressiontests/templates/templatetags/custom.py
114 114 """Expected assignment_params_and_context __doc__""" 115 115 return "assignment_params_and_context - Expected result (context value: %s): %s" % (context['value'], arg) 116 116 assignment_params_and_context.anything = "Expected assignment_params_and_context __dict__" 117 118 register.simple_tag(lambda x: x - 1, name='minusone') 119 120 @register.simple_tag(name='minustwo') 121 def minustwo_overridden_name(value): 122 return value - 2