Articles in this section

hasNoItems helper

Returns true if the input collection (array or object) has no elements or properties.

Usage

{{hasNoItems value}}
  • value (required): The array or object to evaluate

Examples

Check for empty arrays and objects

{{hasNoItems record.arr1}}
{{hasNoItems record.arr2}}
{{hasNoItems record.obj1}}
{{hasNoItems record.obj2}}

Input:

{
  "record": {
    "arr1": [],
    "arr2": [1, 2],
    "obj1": {},
    "obj2": { "x": 1 }
  }
}

Output:

true
false
true
false

Conditional rendering example

{{#if (hasNoItems record.items)}}
  No items found
{{else}}
  Items present
{{/if}}

Input:

{ "record": { "items": [] } }

Output:

No items found

Tip

  • Works for both arrays and plain objects.

  • Returns true only when there are no elements (for arrays) or no keys (for objects).

  • Use with #if or #unless for conditional logic when checking for empty collections.