2 "for" tag iterates over iterable and countable objects
4 {% for item in items %}
6 * {{ loop.index }}/{{ loop.index0 }}
7 * {{ loop.revindex }}/{{ loop.revindex0 }}
8 * {{ loop.first }}/{{ loop.last }}/{{ loop.length }}
12 {% for key, value in items %}
13 * {{ key }}/{{ value }}
16 {% for key in items|keys %}
20 class ItemsIteratorCountable implements Iterator, Countable
22 protected $values = array('foo' => 'bar', 'bar' => 'foo');
23 public function current() { return current($this->values); }
24 public function key() { return key($this->values); }
25 public function next() { return next($this->values); }
26 public function rewind() { return reset($this->values); }
27 public function valid() { return false !== current($this->values); }
28 public function count() { return count($this->values); }
30 return array('items' => new ItemsIteratorCountable())