For populating loops, I get the resultset from db, and assign it directly to 
the loop_var. This works wonderfully for most cases, except where there is a 
need to process each row before assigning it to the template. One particular 
case is where I am retrieving a resultset after a search query, and I need to 
highlight the text that was searched for.

Is there a way I can continue to use the 'single' assignment, and still achieve 
this objective?

Thanks,
Nishi

Here is some code snippet to explain it more:

my $data = &getDataFromDB;
$template->param(myLoopVar => $data);  #preferred way

#BUT, if I need to bold the 'search text', I need to iterate through the loop
my @loopData=();
foreach my $rec (@{$data}) {
  my %loopRow;
  $rec->{title} =~ s/(\b$searchText\b)/<b>$1<\/b>/ig;
  $loopRow{title} = $rec->{title};
  push @loopData, \%loopRow;
}
$template->param(myLoopVar => [EMAIL PROTECTED]);



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642
_______________________________________________
Html-template-users mailing list
Html-template-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/html-template-users

Reply via email to