File: 27_chomp.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 (48 lines) | stat: -rw-r--r-- 941 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
45
46
47
48
use warnings;
use strict;
use lib 't';
use Test::More tests => 3;
use_ok('HTML::Template::Compiled');
use HTC_Utils qw($cache $tdir &cdir);

{
    my $htc = HTML::Template::Compiled->new(
        scalarref => \<<'EOM',
<tmpl_var foo POST_CHOMP=3 >
<tmpl_var  foo >
<!--tmpl_var foo PRE_CHOMP=3 -->
<%var foo PRE_CHOMP=3 POST_CHOMP=3 %>
EOM
        tagstyle => [qw(+classic +asp +comment )],
        debug => 0,
    );
    $htc->param(foo => 23);
    my $out = $htc->output;
    #print "out: $out\n";
    cmp_ok($out, 'eq', '23232323', "chomp");
}

{
    my $htc = HTML::Template::Compiled->new(
        scalarref => \<<'EOM',
<%loop foo %>
* <%= _ %>
<%/loop PRE_CHOMP=3 POST_CHOMP=3 %>
EOM
        tagstyle => [qw(+asp)],
        debug => 0,
    );
    my $exp = <<'EOM';

* 2
* 3
* 4
EOM
    $htc->param(foo => [2..4]);
    chomp($exp);
    my $out = $htc->output;
    #print "out: $out\n";
    cmp_ok($out, 'eq', $exp, "chomp loop");
}