Clinton Gormley wrote:
[SNIP]
The truncate filter doesn't do what I would like it to do.
[SNIP]

sub truncate {
    my ($self,$max,$suffix,$min) = @_;
return $self unless defined $max; $suffix||='';
    my $string = $self->{ text };
    return $self if CORE::length $string < $max;
$max-=length($suffix); $max = 0 if $max < 0;
    unless ($min && $string=~s/^(.{$min,$max})\s.*/$1/e) {
        $string = CORE::substr($string,0,$max);
    }
    $self-> { text } = $string.$suffix;
    return $self;
}
[SNIP]

This code appears to be based on the String plugin rather than the truncate 
filter. Are you trying to change the filter instead or both maybe?

Also, when posting patches (although this appears to be more of a demonstration 
than a patch) it'd be nice to see the diff -u on them rather than straight code 
so that it's easy to view what changes were made. (Be sure to post the version 
# you diff'd on as well.)

The idea doesn't seem too crazy to me, especially since it wouldn't change 
existing behavior.

-- Josh

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

Reply via email to