File: dot_nested.t

package info (click to toggle)
libhtml-template-pluggable-perl 0.17%2B~cs0.6-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 276 kB
  • sloc: perl: 401; makefile: 17
file content (45 lines) | stat: -rw-r--r-- 830 bytes parent folder | download | duplicates (5)
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
39
40
41
42
43
44
45
# use Carp qw(verbose);

use Test::More qw/ no_plan /;

{
    # submitted by Dan Horne
    package T1;
    use strict;

    sub name {
        my $self = shift;
        $self->{name} ||= shift;
        return $self->{name};
    }

    sub greeting {
        my $self = shift;
        my $name = shift;
        return "hello $name";
    }

    sub new {
        my $class = shift;
        bless {}, $class;
    }

    1;
}

use HTML::Template::Pluggable;
use HTML::Template::Plugin::Dot;

my $text = '<tmpl_var name="t.greeting(t.name())">';

my $test = T1->new();
$test->name('bob');
is "hello bob", $test->greeting('bob');
eval {
    my $template = HTML::Template::Pluggable->new(scalarref => \$text);
    $template->param('t' => $test);
    my $out = $template->output;
    is($out, T1->greeting("bob"));
} or warn $@;

__END__