Feature Request: Loop variable inside map filter
Open
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 8.4k
- Forks
- 1.3k
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 37
Description
I really like that twig have a loop variable in its for loops.
It would be great to also have then in a loop with the the map filter. For example:
{% set options = (choices|map((choice) => {
checked: (loop.first and value) and choice.value in value,
})) %}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing how the Twig map filter evaluates its callback and how the loop variable is provided in regular for loops. Check existing filter and loop-related tests before defining the expected behavior for the example; done means callbacks in map can access the appropriate loop state and the behavior is covered by tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- web-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100