Nesting list tags breaks the name_index

Bug #523899 reported by Ben Rometsch
16
This bug affects 3 people
Affects Status Importance Assigned to Milestone
play framework
Status tracked in 1.0
1.0
Fix Released
Medium
Guillaume Bort
1.1
Fix Committed
Medium
Unassigned

Bug Description

If you have two nested lists, e.g.:

#{list list1, as:'list1'}
  ${name_index}

  #{list list2, as:'list2'}
    ${name_index}
  #{/list}
#{/list}

It appears that the name_index context is not specific to the nested list, and so it is incremented in both the outer and inner list.

Revision history for this message
Guillaume Bort (guillaume-bort) wrote : Re: [Bug 523899] [NEW] Nesting list tags breaks the name_index

What is ${name_index} ? It should be ${list1_index} and ${list2_index}

On Thu, Feb 18, 2010 at 4:55 PM, Ben Rometsch <email address hidden> wrote:
> Public bug reported:
>
> If you have two nested lists, e.g.:
>
> #{list list1, as:'list1'}
>  ${name_index}
>
>  #{list list2, as:'list2'}
>    ${name_index}
>  #{/list}
> #{/list}
>
> It appears that the name_index context is not specific to the nested
> list, and so it is incremented in both the outer and inner list.
>
> ** Affects: play
>     Importance: Undecided
>         Status: New
>
> --
> Nesting list tags breaks the name_index
> https://bugs.launchpad.net/bugs/523899
> You received this bug notification because you are subscribed to play
> framework.
>

Revision history for this message
Ben Rometsch (ben-solidstategroup) wrote :

For the inner loop, this works, but the outer loop is still showing the incorrect value...

Revision history for this message
Paul Holt (pcholt) wrote :

I think I found a fix to this. In play.templates.InlineTags there's a loop variable _i which should be _{$index}_i.

Revision history for this message
Paul Holt (pcholt) wrote :

This patch is tested and really really works.

Changed in play:
importance: Undecided → Medium
Revision history for this message
Leo Polovets (lpolovets) wrote :

A different example...

#{list items:0..5, as:'a'}
  ${a_index}
#{/list}

outputs: 1 2 3 4 5 6
(as expected)

However,

#{list items:0..5, as:'a'}
  ${a_index}
  #{list items:0..5, as:'b'}#{/list}
#{/list}

outputs:
1 8 8 8 8 8

The mere presence of a nested list breaks a_index.

Revision history for this message
Paul Holt (pcholt) wrote :

Leo, so did my patch help?

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.