title: Thymeleaf: How to exclude outer tag when using th:each?
body: <p>The Thymeleaf 2.1.4 official doc demonstrates the <code>for each</code> usage as below:</p>
  
  
  
  <pre class="lang-html prettyprint-override"><code> &lt;tr th:each="prod : ${prods}" th:class="${prodStat.odd}? 'odd'"&gt;
      &lt;td th:text="${prod.name}"&gt;Onions&lt;/td&gt;
      &lt;td th:text="${prod.price}"&gt;2.41&lt;/td&gt;
      ...
   &lt;/tr&gt;
  </code></pre>
  
  <p>It generates one <code>&lt;tr&gt;</code> in each iteration, which is perfect fit in this situation. However in my case I don't need the outer tag (here, <code>&lt;tr&gt;</code>).</p>
  
  <hr>
  
  <p>My use case is to generating <code>&lt;bookmark&gt;</code> tag in a recursive way, no other tags include, and a <code>&lt;bookmark&gt;</code> tag must contain a name and href attribute.</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-4.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"&gt;
  &lt;body&gt;
  
  &lt;div th:fragment="locationBookmark(location)"&gt;
      &lt;bookmark th:each="map : ${location.subMaps}"&gt;
          &lt;bookmark th:name="${map.name}"
                    th:href="'#'+${map.id}" th:include=":: locationBookmark(${map})"&gt;
          &lt;/bookmark&gt;
      &lt;/bookmark&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>the including side:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;bookmark th:include="bookmark : locationBookmark(${rootLocation})"/&gt;
  </code></pre>
  
  <p>Many thanks.</p>