File: 01-simple.t

package info (click to toggle)
libtext-microtemplate-perl 0.24-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 296 kB
  • sloc: perl: 1,725; makefile: 2
file content (30 lines) | stat: -rw-r--r-- 495 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
use strict;
use warnings;
use Test::More tests => 4;
use Text::MicroTemplate;

sub foo { '<hr />' }

my $mt = Text::MicroTemplate->new(template => << '...');
abc
?= foo()
def
? 
? 
ghi
...
my $code = eval $mt->code();
ok !$@, $mt->code();
my $got = $code->();
is $got, "abc\n&lt;hr /&gt;\ndef\nghi\n";

$mt = Text::MicroTemplate->new(escape_func => undef);
$mt->parse(<<'...');
abc
?= foo()
def
...
$code = eval $mt->code();
ok !$@, $mt->code();
$got = $code->();
is $got, "abc\n<hr />\ndef\n";