Loops with loops using html-template

Discussion in 'Perl Misc' started by Me, Jan 12, 2006.

  1. Me

    Me Guest

    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>
    Me, Jan 12, 2006
    #1
    1. Advertising

  2. Me

    Paul Lalli Guest

    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
    Paul Lalli, Jan 12, 2006
    #2
    1. Advertising

  3. Me

    Me Guest

    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
    >
    Me, Jan 12, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris Theis
    Replies:
    2
    Views:
    467
    Chris Theis
    Jul 24, 2003
  2. tom_usenet
    Replies:
    0
    Views:
    533
    tom_usenet
    Jul 24, 2003
  3. Replies:
    1
    Views:
    2,102
    Gianni Mariani
    Jun 8, 2007
  4. Peng Yu
    Replies:
    3
    Views:
    768
    Thomas J. Gritzan
    Oct 26, 2008
  5. nguillot
    Replies:
    5
    Views:
    528
Loading...

Share This Page