The #some block helper checks whether at least one element in an array satisfies a condition and renders one expression if true, or an optional {{else}} expression if no elements match. Use it when you need to know whether any element in an array meets a type or value condition.
Syntax
{{#some array conditionFn}} expr {{else}} expr {{/some}}
array -- The array to evaluate. Required.
conditionFn -- The condition to apply to each element. Required. The helper renders the main block if at least one element satisfies the condition. Accepted values: isTruthy, isFalsy, isArray, isString, isObject, isNumber, isBoolean.
Examples
Check if any element has a non-empty value
{{#some record.arr isTruthy}}
At least one element has a value.
{{else}}
N/A
{{/some}}
Input:
{ "record": { "arr": [1, "hello", true] } }
Output: At least one element has a value.
All three elements have non-empty values, so the condition is satisfied and the main block renders.
Check if any element is a number
{{#some record.values isNumber}}
Contains a number.
{{else}}
No numbers.
{{/some}}
Input:
{ "record": { "values": ["apple", false, 42] } }
Output: Contains a number.
42 satisfies isNumber, so the main block renders even though the other elements don't match.
Usage notes
- The main block renders if at least one element satisfies the condition -- not all elements need to match.
- If no elements satisfy the condition and the parameters are valid, the
{{else}}block renders. - The
{{else}}clause is optional. If omitted and no elements match, the helper renders nothing. - To match on object properties within an array, use the #filter helper instead.