Skip to content

Commit

Permalink
filter should accept objects.
Browse files Browse the repository at this point in the history
  • Loading branch information
John Boxall committed May 29, 2013
1 parent 073fdc0 commit 2fff653
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion jinja2/filters.py
Expand Up @@ -183,7 +183,7 @@ def do_title(s):
uppercase letters, all remaining characters are lowercase.
"""
rv = []
for item in re.compile(r'([-\s]+)(?u)').split(s):
for item in re.compile(r'([-\s]+)(?u)').split(soft_unicode(s)):
if not item:
continue
rv.append(item[0].upper() + item[1:])
Expand Down
8 changes: 8 additions & 0 deletions jinja2/testsuite/filters.py
Expand Up @@ -205,6 +205,14 @@ def test_title(self):
tmpl = env.from_string('''{{ "foo\tbar"|title }}''')
assert tmpl.render() == "Foo\tBar"

class Foo:
def __str__(self):
return 'foo-bar'

tmpl = env.from_string('''{{ data|title }}''')
out = tmpl.render(data=Foo())
assert out == 'Foo-Bar'

def test_truncate(self):
tmpl = env.from_string(
'{{ data|truncate(15, true, ">>>") }}|'
Expand Down

0 comments on commit 2fff653

Please sign in to comment.