Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Loops with loops using html-template

Reply
Thread Tools

Loops with loops using html-template

 
 
Me
Guest
Posts: n/a
 
      01-12-2006
How do I contruct an array of hash references( or arrays) such that
I can have the following loops in html-template:

<MAIN_LOOPP>
DATA1
DATAN
<OTHER-LOOP>
O-DATA1
O-DATAN
</OTHER-LOOP>
</MAIN_LOOP>
 
Reply With Quote
 
 
 
 
Paul Lalli
Guest
Posts: n/a
 
      01-12-2006
Me wrote:
> How do I contruct an array of hash references( or arrays) such that
> I can have the following loops in html-template:
>
> <MAIN_LOOPP>
> DATA1
> DATAN
> <OTHER-LOOP>
> O-DATA1
> O-DATAN
> </OTHER-LOOP>
> </MAIN_LOOP>


Assuming you're talking about HTML::Template, the above is not a valid
template file. Perhaps you intended something like this?
<TMPL_LOOP name="main_loop">
<TMPL_VAR name="data">
<TMPL_LOOP name="other_loop">
<TMPL_VAR name="o_data">
</TMPL_LOOP>
</TMPL_LOOP>

In that case, you would construct your data structure like so
[untested]:
my @main_loop = (
{
data=>'data_1',
other_loop => [
o_data => 'o_data1_1',
o_data => 'o_data1_2',
# . . .
o_data => 'o_data1_n',
],
},
{
data=>'data_2',
other_loop => [
o_data => 'o_data2_1',
o_data => 'o_data2_2',
# . . .
o_data => 'o_data2_n',
],
},
# . . .
{
data=>'data_n',
other_loop => [
o_data => 'o_datan_1',
o_data => 'o_datan_2',
# . . .
o_data => 'o_datan_n',
],
},
);
$tmpl->param('main_loop' => \@main_loop);


If I have incorrectly interpreted your request, please post a
short-but-complete *actual* template file that you wish to fill, and
your Perl code that attempts to fill it.

Paul Lalli

 
Reply With Quote
 
 
 
 
Me
Guest
Posts: n/a
 
      01-12-2006
Thanks Paul. You were are correct on all accounts. I put in the
template structure in a hurry, and left out the other details
for easy of a reading.
Paul Lalli wrote:
> Me wrote:
>
>>How do I contruct an array of hash references( or arrays) such that
>>I can have the following loops in html-template:
>>
>> <MAIN_LOOPP>
>> DATA1
>> DATAN
>> <OTHER-LOOP>
>> O-DATA1
>> O-DATAN
>> </OTHER-LOOP>
>> </MAIN_LOOP>

>
>
> Assuming you're talking about HTML::Template, the above is not a valid
> template file. Perhaps you intended something like this?
> <TMPL_LOOP name="main_loop">
> <TMPL_VAR name="data">
> <TMPL_LOOP name="other_loop">
> <TMPL_VAR name="o_data">
> </TMPL_LOOP>
> </TMPL_LOOP>
>
> In that case, you would construct your data structure like so
> [untested]:
> my @main_loop = (
> {
> data=>'data_1',
> other_loop => [
> o_data => 'o_data1_1',
> o_data => 'o_data1_2',
> # . . .
> o_data => 'o_data1_n',
> ],
> },
> {
> data=>'data_2',
> other_loop => [
> o_data => 'o_data2_1',
> o_data => 'o_data2_2',
> # . . .
> o_data => 'o_data2_n',
> ],
> },
> # . . .
> {
> data=>'data_n',
> other_loop => [
> o_data => 'o_datan_1',
> o_data => 'o_datan_2',
> # . . .
> o_data => 'o_datan_n',
> ],
> },
> );
> $tmpl->param('main_loop' => \@main_loop);
>
>
> If I have incorrectly interpreted your request, please post a
> short-but-complete *actual* template file that you wish to fill, and
> your Perl code that attempts to fill it.
>
> Paul Lalli
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
using range() in for loops John Salerno Python 17 04-06-2006 03:14 AM
using threads with for-loops Klaus Neuner Python 10 10-05-2004 08:34 AM
Easy way to alternate output with XSLT when not using templates or loops? Michael Ahlers XML 3 07-15-2004 02:48 PM
Newbee needs Help ref Using Function Statements not Loops(For) jstreet10 Python 1 12-03-2003 06:27 PM
Using Loops to track user input hokiegal99 Python 9 07-21-2003 02:41 PM



Advertisments