Skip to content
Myr

Merge pull request #165 from AquarHEAD/master

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

Update the Docstring of do_truncate in jinja2/filters.py

authored by Armin Ronacher · committed by Armin Ronacher · parents 7e2b823, 8e01f54 · Browse files · 1 file+6 added−5 removed
This commit

State

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

Diff stats

1 file+6 added−5 removed

  • other:+6 added−5 removed

1 file+6 added−5 removed

modified:jinja2/filters.py+6 added-5 removed
443 unmodified lines
444def do_truncate(s, length=255, killwords=False, end='...'):445 """Return a truncated copy of the string. The length is specified446 with the first parameter which defaults to ``255``. If the second447 parameter is ``true`` the filter will cut the text at length. Otherwise448 it will try to save the last word. If the text was in fact448 it will discard the last word. If the text was in fact449 truncated it will append an ellipsis sign (``"..."``). If you want a450 different ellipsis sign than ``"..."`` you can specify it using the451 third parameter.452453 .. sourcecode jinja::453 .. sourcecode:: jinja454455 {{ mytext|truncate(300, false, '&raquo;') }}456 truncate mytext to 300 chars, don't split up words, use a457 right pointing double arrow as ellipsis sign.455 {{ "foo bar"|truncate(5) }}456 -> "foo ..."457 {{ "foo bar"|truncate(5, True) }}458 -> "foo b..."459 """460 if len(s) <= length:461 return s462 elif killwords:
378 unmodified lines