title: Spring - Thymeleaf iteration
body: <p>Suppose I want to obtain a structure like this:</p>
  
  <pre><code>&lt;div&gt;
    &lt;ul&gt;
      &lt;!-- Item --&gt;
      &lt;li class="item"&gt;
        &lt;span class="more no-select" data-target=".item1"&gt;+&lt;/span&gt;
        &lt;span class="right"&gt;&lt;/span&gt;
      &lt;/li&gt;
  
      &lt;!-- Children --&gt;
      &lt;li class="item1 hidden nojs"&gt;
        &lt;span class="spacing"&gt;&lt;/span&gt;
        &lt;a href="mylink"&gt;My link&lt;/a&gt;
      &lt;/li&gt;
      &lt;li class="item1 hidden nojs"&gt;
        &lt;span class="spacing"&gt;&lt;/span&gt;
        &lt;a href="mylink"&gt;My link&lt;/a&gt;
      &lt;/li&gt;
      &lt;li class="item1 hidden nojs"&gt;
        &lt;span class="spacing"&gt;&lt;/span&gt;
        &lt;a href="mylink"&gt;My link&lt;/a&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Basically each <code>item</code> has [0 ... n] <code>children</code>.</p>
  
  <p>To obtain this structure using Thymeleaf I'd start by defining the main items as follow:</p>
  
  <pre><code>&lt;li th:each="item : ${items}"&gt;
    &lt;span class="more no-select" th:attr="data-target='.' + ${item.id}"&gt;+&lt;/span&gt;
    &lt;span class="right"&gt;&lt;/span&gt;
  &lt;/li&gt;
  </code></pre>
  
  <p>But then, being that <code>item</code> is limited in scope, how do I cycle through its <code>item.children</code>?</p>