On Wed, 2003-07-30 at 11:54, Sam Tregar wrote:
> On 30 Jul 2003, Steffen Zeidler wrote:
> > I thought of a new function like global_param() which mainly act like
> > param(). What do you think, Sam?
>
> I'm not in favor, mainly because I think the global_vars option itself
> was a mistake. I think the global_vars behavior - where loops inherit
> variables from their enclosing scope - should have been the default
> behavior all along. In fact, someday I'd like to write a new version
> of HTML::Template where global_vars is always on and much more
> efficient.
>
> -sam
>
I'm glad that is not currently the case though, as i have many a situation where i do
things like:
-------
my $template = new HTML::Template(...);
$data = [
{ first_name => "john", last_name => 'Smith' },
{ first_name => "james", last_name => 'Paul' },
{ first_name => "", last_name => 'Jones' },
];
$template->param(first_name => "simran");
$template->param(users => $data);
------
Main User: <tmpl_var name=first_name>
<tmpl_loop name=users>
First Name: <tmpl_if name=first_name>
<tmpl_var name=first_name>
<tmpl_else>
Unknown (last name is: <tmpl_var name=last_name>)
</tmpl_if>
</tmpl_loop>
-------
If global vars was turned on, then the first_name variable in the loop would be
inherited and would default
to "simran" when unset!!!
The above is a simple example i have just knocked up, but i have many many real world
cases where things like
this happen... and global_vars would really destroy me!
simran.
-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
_______________________________________________
Html-template-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/html-template-users