Skip to content
Myr

Fixed #320

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

authored by Armin Ronacher · committed by Armin Ronacher · parent 74a809e · Browse files · 2 files+10 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+10 added−1 removed

  • other:+10 added−1 removed

2 files+10 added−1 removed

modified:jinja2/testsuite/filters.py+8 added
228 unmodified lines
229 smalldata='foobar baz bar')230 msg = 'Current output: %s' % out231 assert out == 'foobar baz b>>>|foobar baz >>>|foobar baz bar', msg232233 def test_truncate_very_short(self):234 tmpl = env.from_string(235 '{{ "foo bar baz"|truncate(9) }}|'236 '{{ "foo bar baz"|truncate(9, true) }}'237 )238 out = tmpl.render()239 assert out == 'foo ...|foo ba...', out240241 def test_truncate_end_length(self):242 tmpl = env.from_string('{{ "Joel is a slug"|truncate(9, true) }}')243 out = tmpl.render()244 assert out == 'Joel i...', 'Current output: %s' % out
301 unmodified lines
modified:jinja2/filters.py+2 added-1 removed
471 unmodified lines
472 {{ "foo bar baz"|truncate(9, True) }}473 -> "foo ..."474475 """476 if len(s) <= (length + len(end)):476 if len(s) <= length:477 return s478 elif killwords:479 return s[:length - len(end)] + end480
1 unmodified line
482 if len(result) < length:483 result += ' '484 return result + end485486487@environmentfilter488def do_wordwrap(environment, s, width=79, break_long_words=True,489 wrapstring=None):490 """
506 unmodified lines