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<hr />\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";
|