title: Twig - loop through part of an array
body: <p>What I already can do is this:</p>
  
  <pre><code>{% for _item in objects %}
      {{ _item.id }}
  {% endfor %}
  </code></pre>
  
  <p>or this:</p>
  
  <pre><code>{% for i in 0..objects|length-1 %}
      {{ objects[i].id }}
  {% endfor %}
  </code></pre>
  
  <p>To loop though the whole array.</p>
  
  <p>What I want to do is:</p>
  
  <ul>
  <li>loop through a part of an array</li>
  <li>if the end of the array is reached: stop (instead of throwing an exception)</li>
  </ul>
  
  <p>Kinda like this - depending on which is smaller (imagine there are only 5 items):</p>
  
  <pre><code>{% for i in 0.. (10 OR objects|length-1) %}
      {{ objects[i].id }}
  {% endfor %}
  </code></pre>
  
  <p>What's the easiest/shortest way of writing this?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Of course, I could test it in my controller and than pass the result as a variable to the template, but isn't there an easier way?</p>