Checks whether any element in an array satisfies a given condition function. If true for at least one, the main block is rendered; otherwise, the {{else}} block is rendered.
{{#some array conditionFn}} expressionInitial {{else}} expressionElse {{/some}}
-
array (required): array to evaluate
-
conditionFn (required): functionto apply to each element. Valid
conditionFninclude:-
isFalsy
-
isTruthy
-
isArray
-
isString
-
isObject
-
isNumber
-
isBoolean
-
-
Check if any array element is truthy
{{#some record.arr isTruthy}} Truthy {{else}} N/A {{/some}}Input:
{ "record": { "arr": [1, "hello", true] } }Output:
Truthy
-
Check if any array 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
Tip
-
Use
#somewhen you only need to know if at least one match exists, not all elements. -
For arrays of objects where property matching is needed, use
#filter. -
The exhaustive supported list for ConditionFn is
isFalsy,isTruthy,isArray,isString,isObject,isNumber,isBoolean. -
Use #some to check existence of at least one match; if none match but parameters are valid, the {{else}} block renders.