What I already can do is this:
{% for _item in objects %}
{{ _item.id }}
{% endfor %}
or this:
{% for i in 0..objects|length-1 %}
{{ objects[i].id }}
{% endfor %}
To loop though the whole array.
What I want to do is:
- loop through a part of an array
- if the end of the array is reached: stop (instead of throwing an exception)
Kinda like this - depending on which is smaller (imagine there are only 5 items):
{% for i in 0.. (10 OR objects|length-1) %}
{{ objects[i].id }}
{% endfor %}
What's the easiest/shortest way of writing this?
EDIT
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?