Skip to content

Commit 4563805

Browse files
committed
add indexOf() rule for Kirby collection loops
1 parent 51f4780 commit 4563805

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

AGENTS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@ Icons use `currentcolor` and are `aria-hidden="true"` by default. Size them with
149149

150150
Fields store raw strings and need casting (`->toPage()`, `->toFiles()`, `->toBool()`, etc.). For output, use `->esc()` on text fields and `->permalinksToUrls()` on writer fields.
151151

152+
### Collections
153+
154+
Use `$collection->indexOf($item)` instead of `$i => $item` when you need the index in a loop. Kirby collection keys are content-based, not numeric.
155+
152156
### Code Style
153157

154158
Avoid setting preliminary variables in files. Prefer inline expressions instead, unless you'd need to repeat a statement.

0 commit comments

Comments
 (0)