in reply to RFC: CGI::FormBuilder::Template::HTML::LoopedVariables

My appreciation to Beth, who gave me a clue for moving this forward. Here is the code I finally used to achieve me end:

my @loop_data; my $phone_lines; while (my $phone = $sth->fetchrow_hashref()){ my $name = 'group_action_' . $phone->{'phone_number_id'}; my $this_phone_line = $phone_line; my $links = $self->_get_links_for_phone_list($phone->{'phone_numbe +r_id'}); $this_phone_line =~ s/CHECKBOX/<tmpl_var field-$name>/; $this_phone_line =~ s/FNAME/$phone->{'fname'}/; $this_phone_line =~ s/LNAME/$phone->{'lname'}/; $this_phone_line =~ s/EMAIL/$phone->{'email'}/; $this_phone_line =~ s/PHONE/$phone->{'phone'}/; $this_phone_line =~ s/LINKS/$links/; $phone_lines .= $this_phone_line . "\n"; $form->field( name => $name, label => '', type => 'checkbox', options => [ ' ' ], sticky => 0, ); } open('TEMPLATE_COMPILED','>',$template_compiled); open('TEMPLATE','<',$template); while(<TEMPLATE>){ if(m/PHONE_LINE/){ $_ =~ s/PHONE_LINE/$phone_lines/; } print TEMPLATE_COMPILED $_; } close('TEMPLATE'); close('TEMPLATE_COMPILED');
I essentially built the template as I went; and as I created each of the form elements. Accumulated the elements into a scalar and then used a string substitution to stitch together a complete custom template that accomodated the data.

I don't think I will be creating that new module to extend HTML::Template at this time. But thanks anyway. And thank you Beth for pointing the way.

if( $lal && $lol ) { $life++; }
  • Comment on Re: RFC: CGI::FormBuilder::Template::HTML::LoopedVariables, that is a Never Mind
  • Download Code