1
0
mirror of https://github.com/django/django.git synced 2025-10-23 21:59:11 +00:00

Fixed #29654 -- Made text truncation an ellipsis character instead of three dots.

Thanks Sudhanshu Mishra for the initial patch and Tim Graham for the review.
This commit is contained in:
Claude Paroz
2018-08-21 15:28:51 +02:00
parent 939dcff24f
commit 201017df30
14 changed files with 65 additions and 60 deletions

View File

@@ -2265,15 +2265,15 @@ If ``value`` is ``"my FIRST post"``, the output will be ``"My First Post"``.
-----------------
Truncates a string if it is longer than the specified number of characters.
Truncated strings will end with a translatable ellipsis sequence ("...").
Truncated strings will end with a translatable ellipsis character ("…").
**Argument:** Number of characters to truncate to
For example::
{{ value|truncatechars:9 }}
{{ value|truncatechars:7 }}
If ``value`` is ``"Joel is a slug"``, the output will be ``"Joel i..."``.
If ``value`` is ``"Joel is a slug"``, the output will be ``"Joel i"``.
.. templatefilter:: truncatechars_html
@@ -2286,10 +2286,10 @@ are closed immediately after the truncation.
For example::
{{ value|truncatechars_html:9 }}
{{ value|truncatechars_html:7 }}
If ``value`` is ``"<p>Joel is a slug</p>"``, the output will be
``"<p>Joel i...</p>"``.
``"<p>Joel i</p>"``.
Newlines in the HTML content will be preserved.
@@ -2306,7 +2306,7 @@ For example::
{{ value|truncatewords:2 }}
If ``value`` is ``"Joel is a slug"``, the output will be ``"Joel is ..."``.
If ``value`` is ``"Joel is a slug"``, the output will be ``"Joel is "``.
Newlines within the string will be removed.
@@ -2327,7 +2327,7 @@ For example::
{{ value|truncatewords_html:2 }}
If ``value`` is ``"<p>Joel is a slug</p>"``, the output will be
``"<p>Joel is ...</p>"``.
``"<p>Joel is </p>"``.
Newlines in the HTML content will be preserved.
@@ -2454,7 +2454,7 @@ For example::
If ``value`` is ``"Check out www.djangoproject.com"``, the output would be
``'Check out <a href="http://www.djangoproject.com"
rel="nofollow">www.djangopr...</a>'``.
rel="nofollow">www.djangoproj…</a>'``.
As with urlize_, this filter should only be applied to plain text.

View File

@@ -273,6 +273,12 @@ Miscellaneous
* The return value of :func:`django.utils.text.slugify` is no longer marked as
HTML safe.
* The default truncation character used by the :tfilter:`urlizetrunc`,
:tfilter:`truncatechars`, :tfilter:`truncatechars_html`,
:tfilter:`truncatewords`, and :tfilter:`truncatewords_html` template filters
is now the real ellipsis character (``…``) instead of 3 dots. You may have to
adapt some test output comparisons.
.. _deprecated-features-2.2:
Features deprecated in 2.2