title: Twig, add first and last class
body: <p>Let's say I have a for loop like this:</p>
  
  <pre><code>{% for elem in arrMenu %}
      &lt;div class="topmenu-button"&gt;
          &lt;a href="{{ elem.url }}"&gt;{{ elem.name }}&lt;/a&gt;
      &lt;/div&gt;
  {% endfor %}
  </code></pre>
  
  <p>In that form, it would render something like:</p>
  
  <pre><code>&lt;div class="topmenu-button"&gt;&lt;a href="url"&gt;name&lt;/a&gt;&lt;/div&gt;
  &lt;div class="topmenu-button"&gt;&lt;a href="url"&gt;name&lt;/a&gt;&lt;/div&gt;
  &lt;div class="topmenu-button"&gt;&lt;a href="url"&gt;name&lt;/a&gt;&lt;/div&gt;
  &lt;div class="topmenu-button"&gt;&lt;a href="url"&gt;name&lt;/a&gt;&lt;/div&gt;
  </code></pre>
  
  <p>How can twig help me to add first and last classes the the div, so that I would have a result like:</p>
  
  <pre><code>&lt;div class="topmenu-button first"&gt;&lt;a href="url"&gt;name&lt;/a&gt;&lt;/div&gt;
  &lt;div class="topmenu-button"&gt;&lt;a href="url"&gt;name&lt;/a&gt;&lt;/div&gt;
  &lt;div class="topmenu-button"&gt;&lt;a href="url"&gt;name&lt;/a&gt;&lt;/div&gt;
  &lt;div class="topmenu-button last"&gt;&lt;a href="url"&gt;name&lt;/a&gt;&lt;/div&gt;
  </code></pre>