find
Find returns the first element in a slice or map where a field equals the given value.
Find returns the first element in a slice or map where a field equals the given value. Returns a non-fatal error when not found, allowing the default modifier to handle it.
Input
array map
Parameters
| # | Type | Required |
|---|---|---|
| 0 | string | yes |
| 1 | any | yes |
Returns
map
Examples
{{ users | find:'id',42 }}
{{ items | find:'slug','my-item' | default:{} }}How is this guide?