0

I've got nested arrays such as:

"outer" : [
    {
        "inner": [
                    {},
                    {}
                 ]
    },
    {
        "inner": [
                    {},
                    {}
                 ]
    }
]

I neeed to generate an output like:

outer[0].inner[0]

outer[0].inner[1]

outer[1].inner[0]

outer[1].inner[1]

My problem is that once I'm inside the inner context, I do not know the outer index. $idx gives me the index of inner. Is there a way for me to access the outer index inside the inner context?

Template example:

{#outer}
{#inner}

outer[???].inner[{$idx}]

{/inner}
{/outer}
Uwe Keim
  • 39,551
  • 56
  • 175
  • 291

1 Answers1

0

In this case you do not need to know the outer context, you could just pass the outer index($idx) as a parameter.

{#outer}
{#inner outIdx=$idx}
outer[{outIdx}].inner[{$idx}]
{/inner}
{/outer}