foreach $result (keys %{$results_ref}){
$source = $results_ref->{$result}->{abs_path};
$source =~ s#/home/##;
print "<div><img src=\"$source\" /></div>";
}
It seems HTML:Template only support basic syntax. How can I do logic like above with it?
UPDATE
An arrayref to hash is not always enough ,consider the following example:
print $hash{LEFT};
foreach $i ($hash{START}..$hash{END}){
if($pager == $i){
print "<span>$i<span>";
}
else {
print "<span><a href=\"/index.pl?page=$i\">$i</a></span>";
}
How would you do it with arrayref to hash?
If I understand your question correctly I think you are looking for the
TMPL_LOOPtag.Build an array of hashes, and pass that as a variable to
param()call. Then useTMPL_LOOPto build what you were doing in theforeach.Then in the template:
EDIT (response to Update):
Again, if I understand correctly, then I would use different keys to drive the logic of the template loop. You can have
TMPL_IFas part ofTMPL_LOOPTemplate:
EDIT: updated to include $hash{LEFT}