title: Jinja2 / Nunjucks: Different treatment to for-loop elements
body: <p>I have a list:</p>
  
  <pre><code>list = [a, b, c, 1, 2, 3, a, b, c, 1, 2, 3, a, b, c, 1, 2, 3]
  </code></pre>
  
  <p>And I want to show it as a table, where every 4th, 5th &amp; 6th element is styled in its own way, e.g like this.:</p>
  
  <pre><code>&lt;td&gt;&lt;span class="label label-info"&gt;1&lt;/span&gt;&lt;/td&gt;
  &lt;td&gt;&lt;span class="label label-danger"&gt;2&lt;/span&gt;&lt;/td&gt;
  &lt;td&gt;&lt;span class="label label-primary"&gt;3&lt;/span&gt;&lt;/td&gt;
  </code></pre>
  
  <p>I am batching the list into 6er rows to display it as a table like this:</p>
  
  <pre><code>{%- for row in list|batch(6, '&amp;nbsp;') %}
      &lt;tr&gt;
      {%- for column in row %}
          &lt;td&gt;{{ column }}&lt;/td&gt;
      {%- endfor %}
      &lt;/tr&gt;
  {%- endfor %}
  </code></pre>
  
  <p>But I have no idea how to do what I described above. Anybody have an idea?</p>