On Dec 29, 10:01 pm, Alex Gaynor <alex.gay...@gmail.com> wrote:
> Adding the ellepsis is as simple as:
>
> {{ foo|slice:":100" }}{% if foo|length > 100 %}...{% endif %}
>
> Given that the recent expansion of the {% if %} tag makes that so easy
> I don't think it's a compelling reason to add a {% truncate %} tag.
>
> Alex

Thank you for acknowledging that slice is not at all the same thing as
a real truncate.  Having that kind of {% if %} scattered around your
templates is exactly the reason we need a filter.

Perhaps the use case just hasn't been explained enough.
truncate_words is not the same thing, and should indeed be used if you
are truncating a paragraph of text.  truncate comes in when you have a
URL or filename, which won't have any spaces and you don't want to
blow off the end of your div or ruin your table cells.

I guess I don't understand the big drawback?  There is obviously a
need, some quick googling finds quite a few independent
implementations of this filter for Django, plus we have a few patches
submitted, some IRC logs, and the people who've piped up on this list.

Is there a big overhead I'm not seeing in adding this filter, either
in performance or maintenance?  It certainly seems like a lot of users
want it, and as others have said, it probably would garner more usage
than some of the other stranger filters present in core.

-Nic

PS. I agree that smarty's truncate seems like a pretty reasonable spec
if we really want to do it right:
<http://www.smarty.net/manual/en/language.modifier.truncate.php>

I'd be perfectly willing to write up a patch to that spec against the
current code base if I knew it wouldn't languish.

--

You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-develop...@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.


Reply via email to