Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

(jeffa) Re: Nesting <TMPL_LOOP> in HTML::Template

by jeffa (Bishop)
on Aug 28, 2002 at 12:51 UTC ( [id://193437]=note: print w/replies, xml ) Need Help??


in reply to Nesting <TMPL_LOOP> in HTML::Template

Check out (jeffa) Re: Structure for nested html::template loops.

UPDATE:
Here is how i would do it ... this is almost identical to blokhead's answer:

use strict; use HTML::Template; my $html = do{local $/;<DATA>}; my %hash = map { $_ => chr $_ } (97..122); my ($i,$j) = (0,0); my $max = 5; my $table; for (sort keys %hash) { push @{$table->[$j]->{key}},{key => $_}; push @{$table->[$j]->{val}},{val => $hash{$_}}; $j++ unless ++$i % $max; } my $tmpl = HTML::Template->new( scalarref => \$html, ); $tmpl->param( table => $table ); print $tmpl->output; __DATA__ <style type="text/css"> <!-- table { border-style: outset; border-width: thin; } th { border-style: inset; } td { border-style: inset; } --> </style> <tmpl_loop table> <table border="1"> <tr> <th>Key</th> <tmpl_loop key> <td><tmpl_var key></td> </tmpl_loop> </tr> <tr> <th>Val</th> <tmpl_loop val> <td><tmpl_var val></td> </tmpl_loop> </tr> <table> </tmpl_loop>

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://193437]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-04-26 00:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found