So, both these from the docs work fine:

    [% first_three = list.slice(0,2) %]
    [% last_three  = list.slice(-3, -1) %]

But this doesn't:

    [% the_rest = list.slice(3, -1) %]

Might be nice if it did though it's not the real perl behavior.
Not saying it's needed or even a good idea, just throwing it out
there b/c I like the idiom.

So, the "$to" line (Stash.pm):
    'slice' => sub {
        my ($list, $from, $to) = @_;
        $from ||= 0;
        $to = $#$list unless defined $to;
        return [ @$list[$from..$to] ];
    },

becomes...? maybe? (untested)
        $to = @$list + $to if ( $to < 0 and $from > 0 );
        $to = $#$list unless defined $to;


-Ashley


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

Reply via email to