Collection counter starts at 1? #359
Replies: 5 comments
-
@julianrubisch thanks for bringing this up! I just tested a sample Rails partial collection rendering, and it does indeed provide a 0-based index, unlike the ViewComponent counters which are 1-based. Here is the PR where we discussed this feature at length: #306. @jonspalmer @franks921 @tclem can you provide context here? My gut says we should look at switching to zero-based. |
Beta Was this translation helpful? Give feedback.
-
Oh yeah, I'm surprised by this as well. I think 0-based is the way to go. |
Beta Was this translation helpful? Give feedback.
-
Hi @joelhawksley. This was purely semantics as it physically counts each item. I am happy to open a PR and make it 0-based. |
Beta Was this translation helpful? Give feedback.
-
The only case I can think of where 1-based indexing is a thing are database records... |
Beta Was this translation helpful? Give feedback.
-
Upon further reflection it does make more sense sticking to 0-based. I created a PR that reverts it back to the way I had when I first opened the PR #361 |
Beta Was this translation helpful? Give feedback.
-
Is there a specific reason why the
collection_counter
is 1-, not 0-based?I had to do some weird shenanigans rendering the code rather unreasonable when aligning it to a standard Ruby array...
Beta Was this translation helpful? Give feedback.
All reactions