[htmltmpl] naming keys in the <tmpl_loop>
Brought to you by:
samtregar
From: Robert F. <so...@to...> - 2006-10-10 12:01:20
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type"> </head> <body bgcolor="#ffffff" text="#000000"> I am new to the HTML::Template module, as you will see:<br> <br> I have successfully generated the <tmpl_loop> using an array which contains a hash reference.<br> <br> However, in the html page I want to be able to loop through my hash without knowing the names of the keys.<br> What is the best way to do this?<br> <br> eg. in my cgi script I have:<br> <br> <i>my %price_hash = (<br> "key1" => "val1", <br> "key2" => "val2", <br> "key3" => "val3", <br> "key89" => "val89"<br> );<br> <br> push (@price_array, \%price_hash);<br> $param->{"price_loop"} = \@price_array;</i><br> <br> So that in the html page I can use:<br> <i><tmpl_loop name="price_loop"><br> </i><i>....</i><br> <i></tmpl_loop><br> <br> </i>I know I can use <i><br> <tmpl_var name="key89"><br> </i>in the loop, but to output "val89" that relies on me knowing that key89 exists, and its name..<i><br> <br> </i><b>How can I just loop through the hash printing out the keys and values, without knowing the keys?</b><i><br> <br> </i> <div class="moz-signature">-- <br> <p>Robert Franks <br> <br> <br> </p> </div> </body> </html> |