How to render a tree in Twig

I played around with domi27’s idea and came up with this. I made a nested array as my tree, [‘link’][‘sublinks’] is null or another array of more of the same. Templates The sub-template file to recurse with: <!–includes/menu-links.html–> {% for link in links %} <li> <a href=”https://stackoverflow.com/questions/8326482/{{ link.href }}”>{{ link.name }}</a> {% if link.sublinks %} … Read more

Iterating through a JSON object

I believe you probably meant: from __future__ import print_function for song in json_object: # now song is a dictionary for attribute, value in song.items(): print(attribute, value) # example usage NB: You could use song.iteritems instead of song.items if in Python 2.