Skip to content
Myr

Merge pull request #103 from njl/fix-issue-93

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Fix to #93, this time respecting whitespace

authored by Ron DuPlain · committed by Ron DuPlain · parents e5763b3, 8f0c8ee · Browse files · 2 files+16 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+16 added−1 removed

  • other:+16 added−1 removed

2 files+16 added−1 removed

modified:jinja2/testsuite/filters.py+10 added
191 unmodified lines
192193 def test_title(self):194 tmpl = env.from_string('''{{ "foo bar"|title }}''')195 assert tmpl.render() == "Foo Bar"196 tmpl = env.from_string('''{{ "foo's bar"|title }}''')197 assert tmpl.render() == "Foo's Bar"198 tmpl = env.from_string('''{{ "foo bar"|title }}''')199 assert tmpl.render() == "Foo Bar"200 tmpl = env.from_string('''{{ "f bar f"|title }}''')201 assert tmpl.render() == "F Bar F"202 tmpl = env.from_string('''{{ "foo-bar"|title }}''')203 assert tmpl.render() == "Foo-Bar"204 tmpl = env.from_string('''{{ "foo\tbar"|title }}''')205 assert tmpl.render() == "Foo\tBar"206207 def test_truncate(self):208 tmpl = env.from_string(209 '{{ data|truncate(15, true, ">>>") }}|'
187 unmodified lines
modified:jinja2/filters.py+6 added-1 removed
174 unmodified lines
175def do_title(s):176 """Return a titlecased version of the value. I.e. words will start with177 uppercase letters, all remaining characters are lowercase.178 """179 return soft_unicode(s).title()179 rv = []180 for item in re.compile(r'([-\s]+)(?u)').split(s):181 if not item:182 continue183 rv.append(item[0].upper() + item[1:])184 return ''.join(rv)185186187def do_dictsort(value, case_sensitive=False, by='key'):188 """Sort a dict and yield (key, value) pairs. Because python dicts are
640 unmodified lines