1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
use strict;
use warnings;
use Test::More 'no_plan';
use HTML::Template::Pluggable;
use HTML::Template::Plugin::Dot;
{
package My::Auto;
sub new { bless {}, shift }
sub foo { "foo" }
sub AUTOLOAD { "bar" }
}
sub render {
my ($str, @params) = @_;
my $t = HTML::Template::Pluggable->new(
scalarref => \$str, die_on_bad_params => 0
);
$t->param( @params );
return $t->output;
}
my $obj = My::Auto->new;
my $x = render(q{<tmpl_var auto.foo>}, auto => $obj);
is $x, 'foo', 'can("foo")';
is $obj->quux, "bar", "object can autoload";
my $y = render(q{<tmpl_var auto.quux>}, auto => $obj);
is $y, 'bar', 'can("AUTOLOAD")';
__END__
ok 1 - can("foo")
ok 2 - can("AUTOLOAD")
1..2
|