Reputation: 1013
The Symfony framework has loop_index
, first
and last
variables for working with loops.
{% for each link in links %}
{% if loop_index == first %}
.....
{% else %}
....
{%endif %}
{% end %}
Are there such variables or functions in rails?
Upvotes: 0
Views: 43
Reputation: 15788
Not exactly but you can use each_with_index:
{% links.each_with_index do |link, index| %}
{% if index == 0 %}
.....
{% else %}
....
{%endif %}
{% end %}
Upvotes: 3