Hello Robert,

On 10/10/06, Robert Franks <[EMAIL PROTECTED]> wrote:
I am new to the HTML::Template module, as you will see:

I have successfully generated the <tmpl_loop> using an array which contains a hash reference.

However, in the html page I want to be able to loop through my hash without knowing the names of the keys.
What is the best way to do this?


You can do:

my %hash = (
     key1 => 'value1',
     key2 => 'value1',
     keyX => 'valueX',
);

my $tmpl_param = [];
foreach my $key (keys %hash) {
        push @$tmpl_parm, {
               key    => $key,
               value => $hash{$key},
       };
}
$template->param ( parm => $tmpl_parm);


And, in the template:
------------------------

<tmpl_loop $tmpl_parm>
        <tmpl_var key> is <tmpl_var value>  |
</tmpl_loop>



Hope it helps,

matías
 

--
http://confronte.com
Compará y comprá mejor
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Html-template-users mailing list
Html-template-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/html-template-users

Reply via email to