summaryrefslogtreecommitdiff
path: root/docs/ref
diff options
context:
space:
mode:
authorJeremy <saturn5971@gmail.com>2013-01-10 17:27:20 +0800
committerTim Graham <timograham@gmail.com>2014-02-13 10:27:27 -0500
commitf94f466cd3461527fb76a3e8951039a3c2388829 (patch)
treea65d54abff8f37160f6af72542f514dd319a9df7 /docs/ref
parent390001ce52802a7fa1fceeabfb646e6b32911fb9 (diff)
Fixed #19496 -- Added truncatechars_html filter.
Thanks esevece for the suggestion and Nick Sandford and Martin Warne for the inital work on the patch.
Diffstat (limited to 'docs/ref')
-rw-r--r--docs/ref/templates/builtins.txt20
1 files changed, 20 insertions, 0 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