Articles in this section

arrayify helper

The arrayify helper casts the given input into an array.

  • If the input is already an array, it returns it unchanged.

  • If it’s a single value, it wraps that value in an array.

  • If the input is null or undefined, it returns an empty array.

Usage

{{arrayify value}}
  • value (required): any value to cast into an array.

Examples

  • value (required): Any value to cast into an array

Convert values to arrays

{{arrayify record.name}}
{{arrayify record.tags}}

Input:

{
  "record": {
    "name": "foo",
    "tags": ["promo", "sale"]
  }
}

Output:

["foo"]
["promo", "sale"]

Handle null or undefined input

{{arrayify record.missingField}}

Input:

{ "record": {} }

Output:

[]

Convert field value to array

{{arrayify record.test}}

Input:

{
  "record": {"test":"a,b"}
}

Output:

[ "a,b"]

Tip

  • Useful for ensuring consistent array output in loops or mappings.

  • Prevents runtime errors when downstream logic expects arrays.

  • Combine with iteration helpers like #each to handle single or multiple values uniformly.