Hello everybody,

i have the following package definition:
package Collection;
use overload 
        '@{}'   => \&op_deref_array;


sub new {
        # usual new code
        my $self = shift;
        $self->{list} = [];     
}

sub op_deref_array {
        my $object = shift;
        return $object->{list};
}


as i use this in normal Perl like :

my $c = new Collection();
foreach my $x (@{$c}) {
        print $x . "\n";
}

i get the right objects ...

if i use this with template toolkit.
my $c = new Collection();
my $t = new Template();
$t->process('mytemplate.txt', { list => $c });

and where mytemplate.txt looks like 
[% c %]
[% FOREACH x = c %]
[% x %]
[% END %]

i can not see the 'x' in my output. It seems that the overloading of the
@{} operator doesn't work in TT.

any suggestions.

thanks in advance

Gernot

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

Reply via email to