On Mon, Jul 28, 2008 at 3:13 PM, Marc Chantreux <[EMAIL PROTECTED]
> wrote:
> hello Sean,
>
> I'm afraid it does the same ...
>
I'm not sure what you mean. Here's a less abbreviated example:
use Template;
use Template::Stash;
use strict;
package Object;
sub new {
my ($class, $addend) = @_;
bless { addend => $addend }, $class;
}
sub field {
my ($self, $arg) = @_;
return $arg + $self->{addend};
}
package main;
$Template::Stash::HASH_OPS->{dofield} = sub {
my ($fielder, $num) = @_;
return $fielder->field($num + 2);
};
my $obj = Object->new(1);
my $t = Template->new;
$t->process(\'[% obj.dofield(3) %]', { obj => $obj })
or die $t->error;
This prints "6", showing that the hash vmethod "dofield" has dispatched to
the "field" method of $obj.
--Sean
_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates