Monday, 15 June 2015

json - Double output in Twig nested loop -


My data is taken from one of the following formats to the JSON file:

< "[{" Text ":" Subtitle "," URL ":" {{"Text": "Item", "Item", "URL": "URL 1", "Sub" When I try and do:

P>

  & lt; Ul & gt; For item in {% - primeNav.items - item} & lt; Li & gt; & Lt; A href = {{item.url}} & gt; {{- - item.text -}} {% - if item.sub -%} & lt; Ul & gt; For sub ITM in {% - item.sub -%} & lt; Li & gt; & Lt; A href = "{{subItem.url}}" & gt; {{- subItem.text -}} & lt; / A & gt; & Lt; / Li & gt; {% - endfor -%} & lt; / Ul & gt; {% - endif -%} & lt; / A & gt; & Lt; / Li & gt; {% - endfor -%} & lt; / Ul & gt;  

The output I get (without white space):

   

For any reason, send me the & lt; A href = "url" & gt; & Lt; / A & gt; second Ul and each child from it is a method that does not conform to my template.

Any idea will be greatly appreciated.


No comments:

Post a Comment