File: 38_vars.t

package info (click to toggle)
libhtml-template-compiled-perl 1.003-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 772 kB
  • sloc: perl: 4,759; makefile: 5
file content (44 lines) | stat: -rw-r--r-- 932 bytes parent folder | download | duplicates (2)
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

use Test::More tests => 3;
BEGIN { use_ok('HTML::Template::Compiled') };
use lib 't';
use
HTC_Utils qw($cache $tdir &cdir);

{
	my $htc = HTML::Template::Compiled->new(
		scalarref => \<<'EOM',
<%set_var FOO value=.root.foo %>
<%= FOO %>
<%include var_include.html %>
EOM
		debug => 0,
        loop_context_vars => 1,
        path => $tdir,
	);
	$htc->param(
        root => {
            foo => 23,
        },
    );
	my $out = $htc->output;
	$out =~ s/\s+//g;
	cmp_ok($out, "eq", "2323", "set_var, use_vars");
	#print "out: $out\n";
}
{
    eval {
        my $htc = HTML::Template::Compiled->new(
            scalarref => \<<'EOM',
<%set_var name="foo bar" value=.root %>
EOM
            debug => 0,
            loop_context_vars => 1,
            path => $tdir,
        );
    };
    my $error = $@;
#    warn __PACKAGE__.':'.__LINE__.": $error\n";
	cmp_ok($error, "=~", ".*Syntax error in <TMPL_\\*>.*", "invalid set_var");
}