Array Helper
Helper |
Description |
findObjectInArray |
Finds an object in an array based on the specified field name and value. |
findObjectInArray
Finds an object in an array based on the specified field name and value.
Parameters:
Return:
object|null
The first object in the array that matches the criteria, or null if no match is found.
const items = [{id: 123, name: 'Item A'}, {id: 456, name: 'Item B'}];
hbs.compile(
`{{#each items}}
{{#if (eq id 123)}}
{{lookup (findObjectInArray ../items 'id' id) 'name'}}
{{/if}}
{{/each}}`)({items});