"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/HTML/Template.pm" between
HTML-Template-2.95.tar.gz and HTML-Template-2.97.tar.gz

About: HTML-Template is a Perl module to use HTML Templates from CGI scripts.

Template.pm  (HTML-Template-2.95):Template.pm  (HTML-Template-2.97)
package HTML::Template; package HTML::Template;
$HTML::Template::VERSION = '2.95'; $HTML::Template::VERSION = '2.97';
=head1 NAME =head1 NAME
HTML::Template - Perl module to use HTML-like templating language HTML::Template - Perl module to use HTML-like templating language
=head1 SYNOPSIS =head1 SYNOPSIS
First you make a template - this is just a normal HTML file with a few First you make a template - this is just a normal HTML file with a few
extra tags, the simplest being C<< <TMPL_VAR> >> extra tags, the simplest being C<< <TMPL_VAR> >>
skipping to change at line 129 skipping to change at line 129
variables are used. See L<LAZY VALUES> for more information. variables are used. See L<LAZY VALUES> for more information.
=head3 Attributes =head3 Attributes
The following "attributes" can also be specified in template var tags: The following "attributes" can also be specified in template var tags:
=over =over
=item * escape =item * escape
This allows you to escape the value before it's put into the output. Th This allows you to escape the value before it's put into the output.
This is useful when you want to use a TMPL_VAR in a context where those characte rs would This is useful when you want to use a TMPL_VAR in a context where those characte rs would
cause trouble. For example: cause trouble. For example:
<input name=param type=text value="<TMPL_VAR PARAM>"> <input name=param type=text value="<TMPL_VAR PARAM>">
If you called C<param()> with a value like C<sam"my> you'll get in trouble If you called C<param()> with a value like C<sam"my> you'll get in trouble
with HTML's idea of a double-quote. On the other hand, if you use with HTML's idea of a double-quote. On the other hand, if you use
C<escape=html>, like this: C<escape=html>, like this:
skipping to change at line 2190 skipping to change at line 2190
} else { } else {
$var = HTML::Template::VAR->new(); $var = HTML::Template::VAR->new();
$pmap{$name} = $var; $pmap{$name} = $var;
$top_pmap{$name} = HTML::Template::VAR->new() $top_pmap{$name} = HTML::Template::VAR->new()
if $options->{global_vars} and not exists $top_pmap{$name} ; if $options->{global_vars} and not exists $top_pmap{$name} ;
} }
# if a DEFAULT was provided, push a DEFAULT object on the # if a DEFAULT was provided, push a DEFAULT object on the
# stack before the variable. # stack before the variable.
if (defined $default) { if (defined $default) {
push(@pstack, HTML::Template::DEFAULT->new($default)); push(@pstack, HTML::Template::DEF->new($default));
} }
# if ESCAPE was set, push an ESCAPE op on the stack before # if ESCAPE was set, push an ESCAPE op on the stack before
# the variable. output will handle the actual work. # the variable. output will handle the actual work.
# unless of course, they have set escape=0 or escape=none # unless of course, they have set escape=0 or escape=none
if ($escape) { if ($escape) {
if ($escape =~ /^["']?url["']?$/i) { if ($escape =~ /^["']?url["']?$/i) {
push(@pstack, $URLESCAPE); push(@pstack, $URLESCAPE);
} elsif ($escape =~ /^["']?js["']?$/i) { } elsif ($escape =~ /^["']?js["']?$/i) {
push(@pstack, $JSESCAPE); push(@pstack, $JSESCAPE);
skipping to change at line 2695 skipping to change at line 2695
); );
# And with some TMPL_LOOPs: # And with some TMPL_LOOPs:
$self->param( $self->param(
PARAM => 'value', PARAM => 'value',
PARAM2 => 'value', PARAM2 => 'value',
LOOP_PARAM => [{PARAM => VALUE_FOR_FIRST_PASS}, {PARAM => VALUE_ FOR_SECOND_PASS}], LOOP_PARAM => [{PARAM => VALUE_FOR_FIRST_PASS}, {PARAM => VALUE_ FOR_SECOND_PASS}],
ANOTHER_LOOP_PARAM => [{PARAM => VALUE_FOR_FIRST_PASS}, {PARAM => VALUE_ FOR_SECOND_PASS}], ANOTHER_LOOP_PARAM => [{PARAM => VALUE_FOR_FIRST_PASS}, {PARAM => VALUE_ FOR_SECOND_PASS}],
); );
=item 5 - To set the value of a a number of parameters using a hash-ref : =item 5 - To set the value of a number of parameters using a hash-ref :
$self->param( $self->param(
{ {
PARAM => 'value', PARAM => 'value',
PARAM2 => 'value', PARAM2 => 'value',
LOOP_PARAM => [{PARAM => VALUE_FOR_FIRST_PASS}, {PARAM => VA LUE_FOR_SECOND_PASS}], LOOP_PARAM => [{PARAM => VALUE_FOR_FIRST_PASS}, {PARAM => VA LUE_FOR_SECOND_PASS}],
ANOTHER_LOOP_PARAM => [{PARAM => VALUE_FOR_FIRST_PASS}, {PARAM => VA LUE_FOR_SECOND_PASS}], ANOTHER_LOOP_PARAM => [{PARAM => VALUE_FOR_FIRST_PASS}, {PARAM => VA LUE_FOR_SECOND_PASS}],
} }
); );
skipping to change at line 3024 skipping to change at line 3024
# if we don't have anything in the loop, jump to the next part # if we don't have anything in the loop, jump to the next part
if(!@$loop_values) { if(!@$loop_values) {
$x = $line->[HTML::Template::COND::JUMP_ADDRESS] ; $x = $line->[HTML::Template::COND::JUMP_ADDRESS] ;
} }
} }
} }
} }
} }
} elsif ($type eq 'HTML::Template::NOOP') { } elsif ($type eq 'HTML::Template::NOOP') {
next; next;
} elsif ($type eq 'HTML::Template::DEFAULT') { } elsif ($type eq 'HTML::Template::DEF') {
$_ = $x; # remember default place in stack $_ = $x; # remember default place in stack
# find next VAR, there might be an ESCAPE in the way # find next VAR, there might be an ESCAPE in the way
*line = \$parse_stack[++$x]; *line = \$parse_stack[++$x];
*line = \$parse_stack[++$x] *line = \$parse_stack[++$x]
if ref $line eq 'HTML::Template::ESCAPE' if ref $line eq 'HTML::Template::ESCAPE'
or ref $line eq 'HTML::Template::JSESCAPE' or ref $line eq 'HTML::Template::JSESCAPE'
or ref $line eq 'HTML::Template::URLESCAPE'; or ref $line eq 'HTML::Template::URLESCAPE';
# either output the default or go back # either output the default or go back
skipping to change at line 3292 skipping to change at line 3292
# spec is used above. No encapsulation or information hiding is to be # spec is used above. No encapsulation or information hiding is to be
# assumed. # assumed.
package HTML::Template::VAR; package HTML::Template::VAR;
sub new { sub new {
my $value; my $value;
return bless(\$value, $_[0]); return bless(\$value, $_[0]);
} }
package HTML::Template::DEFAULT; package HTML::Template::DEF;
sub new { sub new {
my $value = $_[1]; my $value = $_[1];
return bless(\$value, $_[0]); return bless(\$value, $_[0]);
} }
package HTML::Template::LOOP; package HTML::Template::LOOP;
sub new { sub new {
return bless([], $_[0]); return bless([], $_[0]);
 End of changes. 6 change blocks. 
6 lines changed or deleted 6 lines changed or added

Home  |  About  |  All  |  Newest  |  Fossies Dox  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTPS