Users expect it to be called "truncate", that alone is sufficient reason.
There's truncate_html, truncate_words.

Deprecate slice, move it to "truncate" and add the ellipsis for consistency.
No harm done, happy users.


J. Leclanche / Adys


On Wed, Dec 30, 2009 at 8:01 AM, Alex Gaynor <alex.gay...@gmail.com> wrote:

> On Tue, Dec 29, 2009 at 11:59 PM, John Debs <johnthed...@gmail.com> wrote:
> >
> >
> > On Dec 29, 9:08 pm, James Bennett <ubernost...@gmail.com> wrote:
> >
> >> It is built in, though, it's just called "slice". The only thing
> >> people seem to offer to differentiate this proposal from the existing
> >> filter is that the proposed "truncate" would add an ellipsis at the
> >> end, and honestly I'm not really convinced that's a significant enough
> >> use case to warrant adding another built-in filter.
> >
> > For what it's worth, it's something I've wanted (and wondered about)
> > for several of my projects, and I've heard the same from others. It
> > seems to me that more often than not, developers want an ellipsis when
> > truncating strings like that.
> >
> > I thought about suggesting adding an option to the existing slice
> > filter but I really think that's its own use case and that there
> > should be a new truncatestring filter that matches the syntax of
> > truncatewords.
> >
> > It's especially unclear to new developers that they should accomplish
> > this with slice (and an if statement checking the length of the
> > string) - and it's not very DRY. The convenience of having slice is
> > undermined by the fact that many aren't clever enough to use it this
> > way - it certainly didn't occur to me.
> >
> > So, +1 to this idea.
> >
> > John
> >
> > --
> >
> > 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<django-developers%2bunsubscr...@googlegroups.com>
> .
> > For more options, visit this group at
> http://groups.google.com/group/django-developers?hl=en.
> >
> >
> >
>
> 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
>
> --
> "I disapprove of what you say, but I will defend to the death your
> right to say it." -- Voltaire
> "The people's good is the highest law." -- Cicero
> "Code can always be simpler than you think, but never as simple as you
> want" -- Me
>
> --
>
> 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<django-developers%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/django-developers?hl=en.
>
>
>

--

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