Hello,

when using the FOR loop without loop variable, the variables do not get cleared properly. Attached program shows this. The second output is correct.

Is this behaviour intended or is it a bug?

Thanks, bye, Uwe

#!/usr/bin/perl

use strict;
use warnings;

use Template;

my @data = (
        {a => 1, b => 1},
        {a => 2,       },
        {        b => 3},
);

my $tmpl1 = <<EOF;
[% FOR DATA -%]
a = [% a %], b = [% b %]
[% END -%]
EOF

my $tmpl2 = <<EOF;
[% FOR d = DATA -%]
a = [% d.a %], b = [% d.b %]
[% END -%]
EOF

my $tt2 = Template->new;

$tt2->process(\$tmpl1, {DATA => \...@data});
print "------------\n";
$tt2->process(\$tmpl2, {DATA => \...@data});

__END__

output:

(tmpl1 - wrong)
a = 1, b = 1
a = 2, b = 1
a = 2, b = 3
------------
a = 1, b = 1
a = 2, b = 
a = , b = 3
(tmpl2 - correct)
_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates

Reply via email to