Skip Menu |

This queue is for tickets about the HTML-Template CPAN distribution.

Report information
The Basics
Id: 35534
Status: resolved
Priority: 0/
Queue: HTML-Template

People
Owner: Nobody in particular
Requestors: RSAVAGE [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 2.9
Fixed in: (no value)



Subject: Over-zealous interpolation
Sometimes I want a template to contain 2 copies of a loop, i.e. where the tmpl_loop name is the same in 2 separate loops. However, in one loop I want to use a different number of tmpl_var's than in the other loop. An example will be clearer: #!/usr/bin/perl use strict; use warnings; use HTML::Template; # ----------------- my($template) = HTML::Template -> new(filename => 'x.tmpl'); $template -> param(loop => [{a => 'A', b => 'B'}]); print $template -> output(); First: <tmpl_loop name=loop>'a' is <tmpl_var name=a> and 'b' is <tmpl_var name=b>.</tmpl_loop> Second: <tmpl_loop name=loop>'a' is <tmpl_var name=a>.</tmpl_loop> Notice how the 2nd loop does /not/ refer to tmpl_var b? This dies with: HTML::Template->output() : fatal error in loop output : HTML::Template : Attempt to set nonexistent parameter 'b' - this parameter name doesn't match any declarations in the template file : (die_on_bad_params => 1) at /usr/local/share/perl/5.8.8/HTML/Template.pm line 3068 There are 2 problems here: (1) The error says I'm trying to set 'b', but I'm not. The exact opposite it true: I'm /not/ setting 'b'. This error message is extremely confusing and frustrating. (2) I'd like the code to do as I intend :-).
This is now fixed in Git and will be available in the upcoming 2.10 release.