Ticket #9483: patch_1.diff
File patch_1.diff, 2.2 KB (added by , 16 years ago) |
---|
-
django/template/defaultfilters.py
210 210 211 211 def title(value): 212 212 """Converts a string into titlecase.""" 213 return re.sub("([a-z])'([A-Z])", lambda m: m.group(0).lower(), value.title())213 return re.sub("([a-z])'([A-Z])", lambda m: m.group(0).lower(), ' '.join([x.capitalize() for x in value.split()])) 214 214 title.is_safe = True 215 215 title = stringfilter(title) 216 216 -
tests/regressiontests/defaultfilters/tests.py
100 100 >>> title(u'discoth\xe8que') 101 101 u'Discoth\xe8que' 102 102 103 >>> title('fun&niest li"ne ever') 104 u'Fun&niest Li"ne Ever' 105 103 106 >>> truncatewords(u'A sentence with a few words in it', 1) 104 107 u'A ...' 105 108 -
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 & ..."),