hmm... I dont consider this to be a bug...

here you create a global variable called 'gvar'
> $t->param(gvar     => "global variable");

here you are creating a loop specific variable called 'gvar'
>     { loopvar => "GVar should be set",         gvar => "Loop GVar 1" },

These two 'gvar's are two different variables. 

In this case
>     { loopvar => "GVar should be blank again", gvar => undef         },

you are saying that the loop specific 'gvar' is not part of the loop - ie equivalent 
to:
       { loopvar => "GVar should be blank again" }

thus requesting the outer global gvar to come into scope.

Consider:

t->param(gvar => "Global gvar");
my $gvar_val;
my @loop;
for.... {
  if (something) {
    $gvar_val = "Loop GVar 1";
  } elsif (somethign else) {
    $gvar_val = "";
  }
  my $tmp;
  $tmp->{loopvar} = ...;
  $tmp->{gvar} = $gvar;
  push @loop, $tmp;
}
t->param(testloop =>[EMAIL PROTECTED]);

What would you expect the TMPL_LOOP to do in that example? 
I would have expected that the third iteration to use the global gvar value.

Mathew


> ========================================================================
> test.tmpl:
> ----------
> Global Variable gvar is: <tmpl_var name=gvar>
> 
> Loop: <tmpl_loop name=testloop>
>         loopvar: <tmpl_var name=loopvar>
>         gvar   : <tmpl_var name=gvar>
>       </tmpl_loop>
> ========================================================================
> test.pl
> -------
> 
> use strict;
> use HTML::Template;
> 
> my $t = new HTML::Template(filename => "test.tmpl", global_vars => 1,)
> || die;
> 
> my $testloop = [
>     { loopvar => "GVar should be set",         gvar => "Loop GVar 1" },
>     { loopvar => "GVar should be blank",       gvar => ""            },
>     { loopvar => "GVar should be blank again", gvar => undef         },
> ];
> 
> $t->param(gvar     => "global variable");
> $t->param(testloop => $testloop);
> print $t->output();
> ========================================================================
> 
> When you run test.pl.. you get the following output:
> ------------------------------------------------------------------------
> Global Variable gvar is: global variable
> 
> Loop: 
>         loopvar: GVar should be set 
>         gvar   : Loop GVar 1
>       
>         loopvar: GVar should be blank
>         gvar   : 
>       
>         loopvar: GVar should be blank again
>         gvar   : global variable
> ------------------------------------------------------------------------
> 
> Now, the issue is that "gvar" in the third iteration of the loop,
> "should have been blank"... i explicitely set it to "undef" in the
> code.. however, since global_vars was on, it ignored my "undef". 



-------------------------------------------------------
This SF.Net email is sponsored by Sleepycat Software
Learn developer strategies Cisco, Motorola, Ericsson & Lucent use to
deliver higher performing products faster, at low TCO.
http://www.sleepycat.com/telcomwpreg.php?From=osdnemail3
_______________________________________________
Html-template-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/html-template-users

Reply via email to