App-TemplateServer
view release on metacpan or search on metacpan
t/tt-provider.t view on Meta::CPAN
$tmp->touch('plain.tt', 'this is plain TT');
$tmp->touch('try_include.tt', '>>[% INCLUDE include.tt %]<<');
$tmp->touch('subdir/foo.tt', 'hopefully subdirs also work');
my $ctx = App::TemplateServer::Context->new( data => { foo => 'bar' } );
my $provider = App::TemplateServer::Provider::TT->new(docroot => ["$tmp"]);
is_deeply [sort $provider->list_templates],
[sort qw\include.tt plain.tt try_include.tt subdir/foo.tt\],
'got all expected templates via list_templates';
sub is_rendered($$) {
my $out = $provider->render_template($_[0], $ctx);
chomp $out;
is $out, $_[1],
$_[2] || "$_[0] renders to $_[1]";
}
is_rendered 'plain.tt', 'this is plain TT';
is_rendered 'include.tt', 'this got included';
is_rendered 'try_include.tt', ">>this got included\n<<";
is_rendered 'subdir/foo.tt', 'hopefully subdirs also work';
( run in 0.664 second using v1.01-cache-2.11-cpan-65fba6d93b7 )