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
nullorundefined, it returns an empty array.
-
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
#eachto handle single or multiple values uniformly.