On 2004-09-23, Offer Kaye <[EMAIL PROTECTED]> wrote:
> Hi,
> Say I've for got the following parameter passed to my template:
>   names_loop => $names,
>
> Where $names looks like:
>  $names = 
>  [
>    {name => name1},
>    {name => name2},
>    {name => name3},
>    # ... 50 such names
>  ];
>
> What do I write in my template to print 3 names per line, for example?
> Is this even possible or do I have to re-arrange my data?
> I tried:
>    <tmpl_loop names_loop><tmpl_var name> <tmpl_var name> <tmpl_var name>
>    </tmpl_loop>
>
> But that just printed each name 3 times :-(

So you want your data to look like this?

Name1   Name2   Name3
Name4   Name5   Name6

One option is to  create a nested loop and send that data structure to
the code. It will look like this:

$names = [
  { 
  row => [      
          {name => name1},
          {name => name2},
          {name => name3},
          ], 
  },
  { 
  row => [      
          {name => name3},
          {name => name4},
          {name => name5},
          ], 
        },
];

###

Alternatively, you could try the HTML::Template::Expr module (which I
have never used). It should allow you to express logic like:

"After after third table cell, end the current row and start a new one".
(Hint: use the modulo operator: "%").

        Mark







-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php
_______________________________________________
Html-template-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/html-template-users
  • ... Offer Kaye
    • ... Roger Burton West
    • ... Mark Stosberg
    • ... Jason Purdy
    • ... Carl Franks
    • ... Andrew Brosnan
    • ... Горький Юрий

Reply via email to