diff options
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/ref/templates/builtins.txt | 20 | ||||
| -rw-r--r-- | docs/releases/1.7.txt | 5 |
2 files changed, 24 insertions, 1 deletions
diff --git a/docs/ref/templates/builtins.txt b/docs/ref/templates/builtins.txt index 737224794d..93ec2adab5 100644 --- a/docs/ref/templates/builtins.txt +++ b/docs/ref/templates/builtins.txt @@ -2172,6 +2172,26 @@ For example:: If ``value`` is ``"Joel is a slug"``, the output will be ``"Joel i..."``. +.. templatefilter:: truncatechars_html + +truncatechars_html +^^^^^^^^^^^^^^^^^^ + +.. versionadded:: 1.7 + +Similar to :tfilter:`truncatechars`, except that it is aware of HTML tags. Any +tags that are opened in the string and not closed before the truncation point +are closed immediately after the truncation. + +For example:: + + {{ value|truncatechars_html:9 }} + +If ``value`` is ``"<p>Joel is a slug</p>"``, the output will be +``"<p>Joel i...</p>"``. + +Newlines in the HTML content will be preserved. + .. templatefilter:: truncatewords truncatewords diff --git a/docs/releases/1.7.txt b/docs/releases/1.7.txt index 3519ac5bda..8d2f329fed 100644 --- a/docs/releases/1.7.txt +++ b/docs/releases/1.7.txt @@ -657,7 +657,7 @@ Templates * :func:`django.shortcuts.render()` * :func:`django.shortcuts.render_to_response()` -* The :tfilter:`time` filter now accepts timzone-related :ref:`format +* The :tfilter:`time` filter now accepts timezone-related :ref:`format specifiers <date-and-time-formatting-specifiers>` ``'e'``, ``'O'`` , ``'T'`` and ``'Z'`` and is able to digest :ref:`time-zone-aware <naive_vs_aware_datetimes>` ``datetime`` instances performing the expected @@ -668,6 +668,9 @@ Templates otherwise. It also now accepts an optional ``using`` keyword argument to control which cache it uses. +* The new :tfilter:`truncatechars_html` filter truncates a string to be no + longer than the specified number of characters, taking HTML into account. + Requests ^^^^^^^^ |
