Ticket #9483: patch_2_trunk.diff
File patch_2_trunk.diff, 2.4 KB (added by , 16 years ago) |
---|
-
django/template/defaultfilters.py
1 1 """Default variable filters.""" 2 2 3 3 import re 4 import string 4 5 5 6 try: 6 7 from decimal import Decimal, InvalidOperation, ROUND_HALF_UP … … 245 246 246 247 def title(value): 247 248 """Converts a string into titlecase.""" 248 return re.sub("([a-z])'([A-Z])", lambda m: m.group(0).lower(), value.title())249 return re.sub("([a-z])'([A-Z])", lambda m: m.group(0).lower(), string.capwords(value)) 249 250 title.is_safe = True 250 251 title = stringfilter(title) 251 252 -
tests/regressiontests/defaultfilters/tests.py
113 113 >>> title(u'discoth\xe8que') 114 114 u'Discoth\xe8que' 115 115 116 >>> title('fun&niest li"ne ever') 117 u'Fun&niest Li"ne Ever' 118 116 119 >>> truncatewords(u'A sentence with a few words in it', 1) 117 120 u'A ...' 118 121 -
tests/regressiontests/templates/filters.py
113 113 'filter-stringformat01': ('{% autoescape off %}.{{ a|stringformat:"5s" }}. .{{ b|stringformat:"5s" }}.{% endautoescape %}', {"a": "a<b", "b": mark_safe("a<b")}, u". a<b. . a<b."), 114 114 'filter-stringformat02': ('.{{ a|stringformat:"5s" }}. .{{ b|stringformat:"5s" }}.', {"a": "a<b", "b": mark_safe("a<b")}, u". a<b. . a<b."), 115 115 116 # XXX No test for "title" filter; needs an actual object. 116 # Check if "title" filter doesn't trip over quotes or ampersands 117 'filter-title01': ('{{ a|title }}', {"a": "fun&niest li\"ne ever"}, "Fun&niest Li"ne Ever"), 117 118 118 119 'filter-truncatewords01': ('{% autoescape off %}{{ a|truncatewords:"2" }} {{ b|truncatewords:"2"}}{% endautoescape %}', {"a": "alpha & bravo", "b": mark_safe("alpha & bravo")}, u"alpha & ... alpha & ..."), 119 120 'filter-truncatewords02': ('{{ a|truncatewords:"2" }} {{ b|truncatewords:"2"}}', {"a": "alpha & bravo", "b": mark_safe("alpha & bravo")}, u"alpha & ... alpha & ..."),