title: How can I recursively extract a hierarchical dictionary using a django template?
body: <p>I have hierarchical structure:</p>
  
  <pre><code>{
      "content": "Header 1", 
      "name": "folder/name.txt", 
      "decendent": [
           {
              "content": "Header 2", 
              "name": "folder/subfolder/name.txt", 
              "decendent": null
          }, 
          {
              "content": "Header 3", 
              "name": "folder/subfolder2/name.txt", 
              "decendent": [
                  {
                      "content": "Header 4", 
                      "name": "folder/subfolder2/subsubfolder1/name.txt", 
                      "decendent": null
                  }
                  ... etc.
              ]
          }
      ]
  }
  </code></pre>
  
  <p>I have to unroll it using (as an example) this template:</p>
  
  <pre><code>                {% for key, value in list.items %}
                  &lt;ul class="Container"&gt;
                      &lt;li class="Node ExpandClosed"&gt;
                          &lt;div class="Expand"&gt;
  
                          &lt;/div&gt;
  
  
                          &lt;div class="Content"&gt;
                              &lt;a href="/help/pur/"&gt;
                                  {{ key }}
                              &lt;/a&gt;
                          &lt;/div&gt;
  
                          {% for k, v in value.items %}
                          &lt;ul class="Container"&gt;
                              &lt;li class="Node ExpandClosed"&gt;
                                  &lt;div class="Expand"&gt;
  
                                  &lt;/div&gt;
  
                                  &lt;div class="Content"&gt;
                                      &lt;a href="/help/test/"&gt;
                                          {{ k }}
                                      &lt;/a&gt;
                                  &lt;/div&gt;
                                  {% for k1, v1 in v.items %}
                                  &lt;ul class="Container"&gt;
                                          &lt;li class="Node ExpandClosed"&gt;
                                              &lt;div class="Expand"&gt;
  
                                              &lt;/div&gt;
  
                                              &lt;div class="Content"&gt;
                                                  &lt;a href="/help/test/"&gt;
                                                      {{ k1 }}
                                                  &lt;/a&gt;
                                              &lt;/div&gt;
  
                                              {% for k2, v2 in v1.items %}
                                                      &lt;ul class="Container"&gt;
                                                          &lt;li class="Node ExpandClosed"&gt;
                                                              &lt;div class="Expand"&gt;
  
                                                              &lt;/div&gt;
  
                                                              &lt;div class="Content"&gt;
                                                                  &lt;a href="#" onclick="k2 = '{{ k2 }}'; changeText(k2)"&gt;
                                                                      {{ k2 }}
                                                                  &lt;/a&gt;
                                                              &lt;/div&gt;
                                                          &lt;/li&gt;
                                                      &lt;/ul&gt;
                                              {% endfor %}
                                          &lt;/li&gt;
                                  &lt;/ul&gt;
                                  {% endfor %}
                              &lt;/li&gt;
                          &lt;/ul&gt;
                          {% endfor %}
                      &lt;/li&gt;
                  &lt;/ul&gt;
                  {% endfor %}
  </code></pre>
  
  <p>I have to put the "name" attribute to "a href" tag, and between opening and closing tag extract the "content", for descendents of node I'd like to go through them recursively. Unfortunately, I have no idea how to perform it using django template language considering it's limitations.</p>
  
  <p>Can you help me, please?</p>