=== modified file 'django/template/defaultfilters.py'
|
|
|
172 | 172 | return truncate_html_words(value, length) |
173 | 173 | truncatewords_html = stringfilter(truncatewords_html) |
174 | 174 | |
| 175 | def uncapfirst(value): |
| 176 | "Uncapitalizes the first character of the value" |
| 177 | if len(value) > 1: |
| 178 | if value[1].islower(): |
| 179 | return value[0].lower() + value[1:] |
| 180 | else: |
| 181 | return value |
| 182 | else: |
| 183 | return value.lower() |
| 184 | uncapfirst = stringfilter(uncapfirst) |
| 185 | |
175 | 186 | def upper(value): |
176 | 187 | "Converts a string into all uppercase" |
177 | 188 | return value.upper() |
… |
… |
|
656 | 667 | register.filter(title) |
657 | 668 | register.filter(truncatewords) |
658 | 669 | register.filter(truncatewords_html) |
| 670 | register.filter(uncapfirst) |
659 | 671 | register.filter(unordered_list) |
660 | 672 | register.filter(upper) |
661 | 673 | register.filter(urlencode) |
=== modified file 'django/utils/text.py'
|
|
|
8 | 8 | capfirst = lambda x: x and force_unicode(x)[0].upper() + force_unicode(x)[1:] |
9 | 9 | capfirst = allow_lazy(capfirst, unicode) |
10 | 10 | |
| 11 | # Uncapitalizes the first letter of a string. |
| 12 | def uncapfirst(x): |
| 13 | x = force_unicode(x) |
| 14 | if len(x) > 1: |
| 15 | if x[1].islower(): |
| 16 | return x[0].lower() + x[1:] |
| 17 | else: |
| 18 | return x |
| 19 | else: |
| 20 | return x.lower() |
| 21 | uncapfirst = allow_lazy(uncapfirst, unicode) |
| 22 | |
11 | 23 | def wrap(text, width): |
12 | 24 | """ |
13 | 25 | A word-wrap function that preserves existing line breaks and most spaces in |
=== modified file 'tests/regressiontests/defaultfilters/tests.py'
|
|
|
490 | 490 | u'123' |
491 | 491 | >>> striptags(123) |
492 | 492 | u'123' |
493 | | |
| 493 | >>> uncapfirst('Contact') |
| 494 | u'contact' |
| 495 | >>> uncapfirst('Some field with many words') |
| 496 | u'some field with many words' |
| 497 | >>> uncapfirst('ORM framework') |
| 498 | u'ORM framework' |
494 | 499 | """ |
495 | 500 | |
496 | 501 | from django.template.defaultfilters import * |
=== modified file 'tests/regressiontests/text/tests.py'
|
|
|
35 | 35 | iri_to_uri() is idempotent: |
36 | 36 | >>> iri_to_uri(iri_to_uri(u'red%09ros\xe9#red')) |
37 | 37 | 'red%09ros%C3%A9#red' |
| 38 | |
| 39 | ### uncapfirst ########################################################### |
| 40 | >>> uncapfirst('Contact') |
| 41 | u'contact' |
| 42 | >>> uncapfirst('Some field with many words') |
| 43 | u'some field with many words' |
| 44 | >>> uncapfirst('ORM framework') |
| 45 | u'ORM framework' |
38 | 46 | """ |