Ron Mahoney <[EMAIL PROTECTED]> wrote:
Lori:
The idea behind HTML::Template is that you pass it a reference to a hash and it
uses the keys of the hash as the namespace for that template. Additionally,
for TMPL_LOOP variables you pass a reference to an array as the value to one of the keys in the hash reference that your passing to the template.
The new problem in your template is that you have not passed a value for all
the variables in the template $tmpl_main. The default behavior for
HTML::Template is to complain when a value for a template variable is not found
in the hash reference that has been passed to it. This behavior can be turned
off with die_on_bad_params=>0 passed to HTML::Temaplte->new. Additionally,
inside a TMPL_LOOP, by default, other paramters are not visible. This can be
changed by passing global_vars=>1 to new(). Also, it looks like you got things
a bit confused between your two templates $tmpl_main and $big_tmpl. Now, I'm not quite sure of everything your trying to accomplish, but I think that you probably don't need the separate template for the cell format. And it looks like your trying to correlate the @loop_data and @loop_attrs arrays, which you can't in HTML::Template. You would have to put the data for each row in one hash reference and then all the rows in one array reference (for the TMPL_LOOP var). So for your code above this would work:
#!/usr/bin/perl -w
use strict;
use HTML::Template;my $color1='white';
my $color2='red';
my @loop_data = (
{ col_cfte => 'col_cfte_val1', col_cbud => 'col_cbud_val1', trclass=>'class1', bgcolor=>"$color1", },
{ col_cfte => 'col_cfte_val2', col_cbud => 'col_cbud_val2', trclass=>'class1', bgcolor=>"$color2", },
{ col_cfte => 'col_cfte_val3', col_cbud => 'col_cbud_val3', trclass=>'class1', bgcolor=>"$color1", },
);
my $big_tmpl = HTML::Template->new(
die_on_bad_params=>0,
global_vars=>1,
filehandle => \*DATA,
);
$big_tmpl->param(
{
title_bar => 'Rpt 1',
hdr_asofdt => 'Today',
attr_fyr => 'someval',
passdata => [EMAIL PROTECTED],
}
);
print $big_tmpl->output;
__DATA__bgcolor= > style="cursor:pointer;cursor:hand;"
title="Click to drill down"
bgcolor">';"
>style="cursor:pointer;cursor:hand;"
title="Click to drill down"
bgcolor">';"
>
Unless there is something else you are trying to accomplish here.
Regards,
Ron
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes