On Mar 22, 2007, at 17:39, Clinton Gormley wrote:

Hi all

The truncate filter doesn't do what I would like it to do.

Write another filter then.


I would prefer if it broke on whitespace, rather than at the exact
length that I specify.

I wouldn't for reasons explained below I don't think that what you are proposing is a bad filter in any way shape or form. I think it's a very good idea. However,
I don't think it's a good idea to modify the existing truncate.



So I'd prefer : "the cat sat on the..."
           to : "the cat sat on the m..."

However, I'd prefer : "I said supercalafragalisticexpial..."
                 to : "I said..."

I propose adding an extra parameter on the end : $min.  So if it can
break on white space and still return a string longer than $min, then it
does so, and if not, then it breaks on $max.

If $min is not specified, then the behaviour will be as before. So this change will be backwards compatible, and won't break any existing code:

Whilst it won't break any existing code it modifies the semantics of the existing filter. What I mean is that you have changed the meaning of the existing parameter when the new parameter is supplied because whitespace has nothing to do with the truncate filter
at present.  When $min is supplied, $max means something different.

I don't think that overloading the semantics in this way is a good idea at all.

How about truncate_words as a new filter that does what you are suggesting?

Of course, really this comes down to ABW I guess.

cheers

nic


_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to