Re: Bug in die_on_bad_params handling

Jason Purdy <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.html-template
Organization Journalistic, Inc.
Message-ID <[email protected]>
IMVHO, this isn't a bug, but rather the intended behavior.  If you 
really want to be strict about it, set up two different loops. 
Otherwise, don't worry about die_on_bad_params.

- Jason

Matija Grabnar wrote:
> For example
> Template:
> 
> <tmpl_loop name="foo">
>  <tmpl_var name="bar">
>  <tmpl_var name="baz">
> </tmpl_loop>
> <tmpl_loop name="foo">
>  <tmpl_var name="baz">
> </tmpl_loop>
> 
> Script:
> #!/usr/bin/perl
> use HTML::Template;
> $t=HTML::Template->new(filename=>'0.tmpl');
> @foo=({bar=>1,baz=>2},{bar=>3,baz=>4});
> $t->param(foo=>\@foo);
> print $t->output;
> 
> Result:
> HTML::Template->output() : fatal error in loop output : HTML::Template : 
> Attempt to set nonexistent parameter 'bar' - this parameter name doesn't 
> match any declarations in the template file : (die_on_bad_params => 1) 
> at /usr/share/perl5/HTML/Template.pm line 2905
> at 0.pl line 6
> at /usr/share/perl5/HTML/Template.pm line 2613
>        HTML::Template::output('HTML::Template=HASH(0x81f283c)') called 
> at 0.pl line 6
> 
> Obviously, this error is wrong: bar does appear, just not in EVERY 
> instance of the loop. I could
> turn die_on_bad_params off, but then I don't get help in finding REAL 
> errors, and I need it
> (because the actual template where I need this is much, much more 
> complex than this
> example).
> 
> 
> -------------------------------------------------------
> SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
> from IBM. Find simple to follow Roadmaps, straightforward articles,
> informative Webcasts and more! Get everything you need to get up to
> speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
> _______________________________________________
> Html-template-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/html-template-users


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.