diff options
author | Armin Ronacher <armin.ronacher@active-4.com> | 2013-08-07 12:53:03 +0100 |
---|---|---|
committer | Armin Ronacher <armin.ronacher@active-4.com> | 2013-08-07 12:53:03 +0100 |
commit | 2ea663b17fe13ff0d6f888f2ba7367180861456e (patch) | |
tree | e48b8e4ece641d99f440458b806aa1d52c142cb6 | |
parent | 563fd2e74af39a75bbc4eee451d4570d20e0beec (diff) | |
download | jinja2-2ea663b17fe13ff0d6f888f2ba7367180861456e.tar.gz |
Corrected title filter behavior.
The title filter will now correctly lowercase the non first letter
like the regular Python filter does.
This fixes #251.
-rw-r--r-- | CHANGES | 2 | ||||
-rw-r--r-- | jinja2/filters.py | 2 | ||||
-rw-r--r-- | jinja2/testsuite/filters.py | 2 |
3 files changed, 5 insertions, 1 deletions
@@ -13,6 +13,8 @@ Version 2.7.1 - Fixed some warnings with hashing of undefineds and nodes if Python is run with warnings for Python 3. - Added support for properly hashing undefined objects. +- Fixed a bug with the title filter not working on already uppercase + strings. Version 2.7 ----------- diff --git a/jinja2/filters.py b/jinja2/filters.py index 49e82aa..fd0db04 100644 --- a/jinja2/filters.py +++ b/jinja2/filters.py @@ -186,7 +186,7 @@ def do_title(s): for item in re.compile(r'([-\s]+)(?u)').split(s): if not item: continue - rv.append(item[0].upper() + item[1:]) + rv.append(item[0].upper() + item[1:].lower()) return ''.join(rv) diff --git a/jinja2/testsuite/filters.py b/jinja2/testsuite/filters.py index 1e1706f..282dd2d 100644 --- a/jinja2/testsuite/filters.py +++ b/jinja2/testsuite/filters.py @@ -208,6 +208,8 @@ class FilterTestCase(JinjaTestCase): assert tmpl.render() == "Foo-Bar" tmpl = env.from_string('''{{ "foo\tbar"|title }}''') assert tmpl.render() == "Foo\tBar" + tmpl = env.from_string('''{{ "FOO\tBAR"|title }}''') + assert tmpl.render() == "Foo\tBar" def test_truncate(self): tmpl = env.from_string( |