push

push adds an element to an array.

Example

{% json sample_array %}
    [
        "element1",
        "element2",
        "element3"
    ]
{% endjson $}
{% assign sample_array = sample_array | push: "element4" %}

Now the content of sample_array is: ["element1", "element2", "element3", "element4"]

Using push with assign might significantly slow down your script. Each time new element is added - new array variable is created. It is recommended to use push tag when adding items to an array.

Last updated