in reply to Column Count w/ HTML::Template

<table> <tmpl_loop foo> <tr> <tmpl_loop bar> <td> <tmpl_var one> <tmpl_var two> </td> </tmpl_loop> </tr> </tmpl_loop> </table> <code> <br> <code> $ht=new HTML::Template(); my @data= ( { bar => [one => 'stuff', two => 'otherstuff'] }, { bar => [one => 'stuff2', two => 'otherstuff2'] } ); $ht->params(foo=>[@data]); print $ht->output;
In other words, nest tmpl_loops.

Replies are listed 'Best First'.
2Re: Column Count w/ HTML::Template
by jeffa (Bishop) on Nov 02, 2003 at 14:43 UTC
    use strict; use warnings; use HTML::Template; my $template = HTML::Template->new(filehandle => \*DATA); $template->param(foo => [ { bar => [{one => 'stuff', two => 'otherstuff'}] }, { bar => [{one => 'stuff2', two => 'otherstuff2'}] } ]); print $template->output; __DATA__ <table> <tmpl_loop foo> <tr> <tmpl_loop bar> <td> <tmpl_var one><br/> <tmpl_var two> </td> </tmpl_loop> </tr> </tmpl_loop> </table>
    In other words, please post complete examples (no assembly required) and make sure your code works first (you left out some important curly braces that enable your code to compile).

    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)