incorrectly terminating a (use ) at $fname : line $fcounter.\n"
if ($cond->[HTML::Template::COND::WHICH] == HTML::Template::COND::WHICH_IF);
}
# connect the matching to this "address" - place a NOOP to
# hold the spot. This allows output() to treat an IF in the
# assembler-esque "Conditional Jump" mode.
push(@pstack, $NOOP);
$cond->[HTML::Template::COND::JUMP_ADDRESS] = $#pstack;
} elsif ($which eq 'TMPL_ELSE') {
$options->{debug} and print STDERR "### HTML::Template Debug ### $fname : line $fcounter : ELSE\n";
my $cond = pop(@ifstack);
die "HTML::Template->new() : found with no matching or at $fname : line $fcounter." unless defined $cond;
die "HTML::Template->new() : found second tag for or at $fname : line $fcounter." if $cond->[HTML::Template::COND::IS_ELSE];
my $else = HTML::Template::COND->new($cond->[HTML::Template::COND::VARIABLE]);
$else->[HTML::Template::COND::WHICH] = $cond->[HTML::Template::COND::WHICH];
$else->[HTML::Template::COND::UNCONDITIONAL_JUMP] = 1;
$else->[HTML::Template::COND::IS_ELSE] = 1;
# need end-block resolution?
if (defined($cond->[HTML::Template::COND::VARIABLE_TYPE])) {
$else->[HTML::Template::COND::VARIABLE_TYPE] = $cond->[HTML::Template::COND::VARIABLE_TYPE];
} else {
push(@ucstack, $else);
}
push(@pstack, $else);
push(@ifstack, $else);
# connect the matching to this "address" - thus the if,
# failing jumps to the ELSE address. The else then gets
# elaborated, and of course succeeds. On the other hand, if
# the IF fails and falls though, output will reach the else
# and jump to the /if address.
$cond->[HTML::Template::COND::JUMP_ADDRESS] = $#pstack;
} elsif ($which eq 'TMPL_INCLUDE') {
# handle TMPL_INCLUDEs
$options->{debug} and print STDERR "### HTML::Template Debug ### $fname : line $fcounter : INCLUDE $name \n";
# no includes here, bub
$options->{no_includes} and croak("HTML::Template : Illegal attempt to use TMPL_INCLUDE in template file : (no_includes => 1)");
my $filename = $name;
# look for the included file...
my $filepath;
if ($options->{search_path_on_include}) {
$filepath = $self->_find_file($filename);
} else {
$filepath = $self->_find_file($filename,
[File::Spec->splitdir($fstack[-1][0])]
);
}
die "HTML::Template->new() : Cannot open included file $filename : file not found."
unless defined($filepath);
die "HTML::Template->new() : Cannot open included file $filename : $!"
unless defined(open(TEMPLATE, $filepath));
# read into the array
my $included_template = "";
while(read(TEMPLATE, $included_template, 10240, length($included_template))) {}
close(TEMPLATE);
local $HTML::Template::this_file = $filepath;
# call filters if necessary
$self->_call_filters(\$included_template) if @{$options->{filter}};
if ($included_template) { # not empty
# handle the old vanguard format - this needs to happen here
# since we're not about to do a next CHUNKS.
$options->{vanguard_compatibility_mode} and
$included_template =~ s/%([-\w\/\.+]+)%//g;
# collect mtimes for included files
if ($options->{cache} and !$options->{blind_cache}) {
$self->{included_mtimes}{$filepath} = (stat($filepath))[9];
}
# adjust the fstack to point to the included file info
push(@fstack, [$filepath, 1,
scalar @{[$included_template =~ m/(\n)/g]} + 1]);
(*fname, *fcounter, *fmax) = \ ( @{$fstack[$#fstack]} );
# make sure we aren't infinite