Skip to content

Support lambda expressions as filter arguments.#16

Merged
jg-rp merged 14 commits intomainfrom
lambda-expressions
Jan 22, 2025
Merged

Support lambda expressions as filter arguments.#16
jg-rp merged 14 commits intomainfrom
lambda-expressions

Conversation

@jg-rp
Copy link
Owner

@jg-rp jg-rp commented Jan 18, 2025

See #15

We've allowed for lambda expressions with multiple arguments. For an array input, a two-argument lambda expression is implicitly passed the item followed by the item's index in the array.. (item, index) => item.foo and index < 3.

Although not used by any filters at the moment, a two-argument lambda expression would be more useful if applied to a mapping/dictionary/hash/object, as it could be passed property/value pairs, one pair for each entry in the mapping.. (key, value) => key contains 'foo' and value.bar == '42'.

@jg-rp jg-rp linked an issue Jan 18, 2025 that may be closed by this pull request
@jg-rp jg-rp marked this pull request as ready for review January 22, 2025 11:42
@jg-rp jg-rp merged commit 6666c72 into main Jan 22, 2025
28 checks passed
@jg-rp jg-rp deleted the lambda-expressions branch January 22, 2025 11:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lambda expressions in Liquid

1 participant