EOT
eval { HTML::Template->new_scalar_ref(\$tmpl_text) };
like($@, qr/DEFAULT option invalid/, "Escape not in TMPL_VAR");
# testing line 1984 else
# not quite checking 1984, deserves some sober attention
$tmpl_text = <
Name:
Job:
EOT
ok(HTML::Template->new_scalar_ref(\$tmpl_text, strict => 0), "Ignores invalid TMPL tags with strict off");
# now with strict on
eval { HTML::Template->new_scalar_ref(\$tmpl_text, strict => 1) };
like($@, qr/Syntax error/, "Spits at invalid TMPL tag with strict on");
# make sure we can use and syntax
my $tmpl = HTML::Template->new(scalarref => \':');
$tmpl->param(foo => 'a');
my $output = $tmpl->output;
is($output, 'a:a', 'both var forms worked');
# attempting to check lines 1540-44
# test using HTML_TEMPLATE_ROOT with path
{
my $file = 'four.tmpl'; # non-existent file
local $ENV{HTML_TEMPLATE_ROOT} = "templates";
eval { HTML::Template->new(path => ['searchpath'], filename => $file) };
like($@, qr/Cannot open included file $file/, "Template file not found");
}
{
my $file = 'four.tmpl'; # non-existent file
local $ENV{HTML_TEMPLATE_ROOT} = "templates";
eval { HTML::Template->new(filename => $file); };
like($@, qr/Cannot open included file $file/, "Template file not found");
}
{
my ($template, $output);
local $ENV{HTML_TEMPLATE_ROOT} = "templates";
$template = HTML::Template->new(filename => 'searchpath/three.tmpl');
$output = $template->output;
ok($output =~ /THREE/, "HTML_TEMPLATE_ROOT working without 'path' option being set");
}
=head1 NAME
t/02-parse.t
=head1 OBJECTIVE
Test previously untested code inside C. Much
remains to be done.
=cut
HTML-Template-2.97/t/04-escape.t 0000644 0001750 0001750 00000022101 13107402001 014203 0 ustar sam sam use strict;
use Test::More (tests => 117);
use_ok('HTML::Template');
while () {
chomp;
next if /^$/;
next if /^#/;
my ($text, $given, $wanted) = split /\|/;
my $template = HTML::Template->new(
scalarref => \$text,
default_escape => "HTML"
);
undef $given if $given eq 'undef';
$template->param(foo => $given);
my $output = $template->output;
is($output, $wanted, $text);
}
# use pipe as the seperator between fields.
# the TMPL_VAR name should always be 'foo'
# fields: TMPL_VAR|given string|escaped string
__DATA__
# use default escaping
|this is bold\n|<b>this is bold\n
|this is bold\n|<b>this is bold\n
|this is bold\n|<b>this is bold\n
|this is bold\n|<b>this is bold\n
|this is bold\n|<b>this is bold\n
|this is bold\n|<b>this is bold\n
|this is bold\n|<b>this is bold\n
|this is bold\n|<b>this is bold\n
|this is bold\n|<b>this is bold\n
# use js escaping
|this is bold\n|this is bold\\n
|this is bold\n|this is bold\\n
|this is bold\n|this is bold\\n
|this is bold\n|this is bold\\n
|this is bold\n|this is bold\\n
|this is bold\n|this is bold\\n
|this is bold\n|this is bold\\n
|this is bold\n|this is bold\\n
|this is bold\n|this is bold\\n
|this is bold\n|this is bold\\n
|this is bold\n|this is bold\\n
|this is bold\n|this is bold\\n
|this is bold\n|this is bold\\n
|this is bold\n|this is bold\\n
|this is bold\n|this is bold\\n
|this is bold\n|this is bold\\n
|this is bold\n|this is bold\\n
|this is bold\n|this is bold\\n
|this is bold\n|this is bold\\n
|this is bold\n|this is bold\\n
|this is bold\n|this is bold\\n
#use url escaping
|this is bold\n|%3Cb%3Ethis%20is%20bold%5Cn
|this is bold\n|%3Cb%3Ethis%20is%20bold%5Cn
|this is bold\n|%3Cb%3Ethis%20is%20bold%5Cn
|this is bold\n|%3Cb%3Ethis%20is%20bold%5Cn
|this is bold\n|%3Cb%3Ethis%20is%20bold%5Cn
|this is bold\n|%3Cb%3Ethis%20is%20bold%5Cn
|this is bold\n|%3Cb%3Ethis%20is%20bold%5Cn
|this is bold\n|%3Cb%3Ethis%20is%20bold%5Cn
|this is bold\n|%3Cb%3Ethis%20is%20bold%5Cn
|this is bold\n|%3Cb%3Ethis%20is%20bold%5Cn
|this is bold\n|%3Cb%3Ethis%20is%20bold%5Cn
|this is bold\n|%3Cb%3Ethis%20is%20bold%5Cn
|this is bold\n|%3Cb%3Ethis%20is%20bold%5Cn
|this is bold\n|%3Cb%3Ethis%20is%20bold%5Cn
|this is bold\n|%3Cb%3Ethis%20is%20bold%5Cn
|this is bold\n|%3Cb%3Ethis%20is%20bold%5Cn
|this is bold\n|%3Cb%3Ethis%20is%20bold%5Cn
|this is bold\n|%3Cb%3Ethis%20is%20bold%5Cn
|this is bold\n|%3Cb%3Ethis%20is%20bold%5Cn
|this is bold\n|%3Cb%3Ethis%20is%20bold%5Cn
|this is bold\n|%3Cb%3Ethis%20is%20bold%5Cn
|this is bold\n|%3Cb%3Ethis%20is%20bold%5Cn
# no escaping
|this is bold\n|this is bold\n
|this is bold\n|this is bold\n
|this is bold\n|this is bold\n
|this is bold\n|this is bold\n
|this is bold\n|this is bold\n
|this is bold\n|this is bold\n
|this is bold\n|this is bold\n
|this is bold\n|this is bold\n
|this is bold\n|this is bold\n
|this is bold\n|this is bold\n
|this is bold\n|this is bold\n
|this is bold\n|this is bold\n
|this is bold\n|this is bold\n
|this is bold\n|this is bold\n
|this is bold\n|this is bold\n
|this is bold\n|this is bold\n
|this is bold\n|this is bold\n
|this is bold\n|this is bold\n
|this is bold\n|this is bold\n
|this is bold\n|this is bold\n
|this is bold\n|this is bold\n
|this is bold\n|this is bold\n
# no escaping
|this is bold\n|this is bold\n
|this is bold\n|this is bold\n
|this is bold\n|this is bold\n
|this is bold\n|this is bold\n
|this is bold\n|this is bold\n
|this is bold\n|this is bold\n
|this is bold\n|this is bold\n
|this is bold\n|this is bold\n
|this is bold\n|this is bold\n
|this is bold\n|this is bold\n
|this is bold\n|this is bold\n
|this is bold\n|this is bold\n
|this is bold\n|this is bold\n
|this is bold\n|this is bold\n
|this is bold\n|this is bold\n
|this is bold\n|this is bold\n
|this is bold\n|this is bold\n
|this is bold\n|this is bold\n
|this is bold\n|this is bold\n
|this is bold\n|this is bold\n
|this is bold\n|this is bold\n
|this is bold\n|this is bold\n
#no escaping and default escaping
|this is bold\n|this is bold\n <b>this is bold\n
|this is bold\n|this is bold\n <b>this is bold\n
# mixing escape and default
|flpper|fl<i>pper
|flpper|fl<i>pper
|flpper|fl<i>pper
|undef|UNKNOWN VALUE
|undef|UNKNOWN VALUE
|undef|UNKNOWN VALUE
|flpper|fl<i>pper
|flpper|fl<i>pper
|flpper|fl<i>pper
|undef|UNKNOWN VALUE
|undef|UNKNOWN VALUE
|undef|UNKNOWN VALUE
|flpper|fl<i>pper
|flpper|fl<i>pper
|flpper|fl<i>pper
|undef|UNKNOWN VALUE
|undef|UNKNOWN VALUE
|undef|UNKNOWN VALUE
HTML-Template-2.97/t/11-non-file-templates.t 0000644 0001750 0001750 00000002615 13107402001 016454 0 ustar sam sam use strict;
use Test::More qw(no_plan);
# tests => 6;
use_ok('HTML::Template');
my ($output, $template, $result);
my ($fh, $template_string, @template_array, $stemplate, $atemplate, $ftemplate, $fhtemplate, $typetemplate);
$template = HTML::Template->new(
path => 'templates',
filename => 'simple.tmpl',
debug => 0
);
open $fh, 'templates/simple.tmpl'
or die "Couldn't open simple.tmpl for reading: $!";
{
local $/;
$template_string = <$fh>;
seek $fh, 0, 0;
}
@template_array = <$fh>;
seek $fh, 0, 0;
$stemplate = HTML::Template->new_scalar_ref(\$template_string, debug => 0);
$atemplate = HTML::Template->new_array_ref(\@template_array, debug => 0);
$ftemplate = HTML::Template->new_file(
'simple.tmpl',
path => 'templates',
debug => 0
);
$fhtemplate = HTML::Template->new_filehandle($fh, debug => 0);
$typetemplate = HTML::Template->new(
type => 'filename',
path => 'templates',
source => 'simple.tmpl',
debug => 0
);
for my $t ($template, $stemplate, $atemplate, $ftemplate, $fhtemplate, $typetemplate) {
$t->param('ADJECTIVE', 'very');
$output = $t->output;
ok(($output !~ /ADJECTIVE/ and $t->param('ADJECTIVE') eq 'very'), 'simple template passes');
}
=head1 NAME
t/11-non-file-templates.t
=head1 OBJECTIVE
Test whether simple output is correctly created when the template source
is a string, array or a filehandle.
=cut
HTML-Template-2.97/t/testlib/ 0000775 0001750 0001750 00000000000 13107402001 014011 5 ustar sam sam HTML-Template-2.97/t/testlib/IO/ 0000775 0001750 0001750 00000000000 13107402001 014320 5 ustar sam sam HTML-Template-2.97/t/testlib/IO/Capture.pm 0000644 0001750 0001750 00000026337 13107402001 016272 0 ustar sam sam package IO::Capture;
$VERSION = 0.05;
use strict;
use Carp;
=head1 NAME
C - Abstract Base Class to build modules to capture output.
=head1 DESCRIPTION
The C Module defines an abstract base class that can be
used to build modules that capture output being sent on a filehandle
such as STDOUT or STDERR.
Several modules that come with the distribution do just that.
I.e., Capture STDOUT and STDERR. Also see James Keenan's
C on CPAN.
See L