Rails can render partial collection with counter:
= render partial: 'item', collection: @items
inside _item.html, rails provides iteration counter for the items. (here)
= item_counter
How to make an alias for item_counter e.g. partial_counter? Or anything that will make it become more DRY? It’s quite ineffisient writing item_counter, product_counter, category_counter, user_counter, .... thx
UPDATED: Alias counter only:
Unfortunately there is no any other Rails’ ways to do what you looking for. You have to define new local variable and assign counter value in all partials by hands: