]> git.ipfire.org Git - thirdparty/jinja.git/commit
Fix and improve do_truncate 610/head
authorjab <jab@users.noreply.github.com>
Sat, 24 Sep 2016 21:25:31 +0000 (21:25 +0000)
committerjab <jab@users.noreply.github.com>
Sat, 24 Sep 2016 21:25:31 +0000 (17:25 -0400)
commit9f9606bc93da879db2071c2112f90437c5ac2eb3
treebc163f1808e1d42ded8f567c1984bbed8f33aba3
parent390c3cec2bbab50d0ba276d8fea61e27d582172a
Fix and improve do_truncate

- Ensure that the requested max length be at least as long as the
  requested `end` value (e.g. 3 in the case of '...'). Fixes #539
- Add `leeway` parameter so that strings that just barely miss the
  requested max length cutoff can still be spared from unwanted truncation.
  Default value is 5.
- No longer append a space before appending `end` under any circumstances.
  Adding whitespace before ellipsis punctuation in English is grammatically
  incorrect.
jinja2/filters.py
tests/test_filters.py