Within Fluid itself, the only way to create a simple array is to split a string.

{% assign children = "Alec,Gabrielle,Isabella" | split:"," %}

For simple arrays, you can access values by numeric index, as normal.

{{ children[0] }}

Note that an invalid index won’t throw an error, it just won’t return anything.

There are also several virtual members available.

{{ children.first }}
{{ children.last }}
{{ children.size }}

There is no way to create a dictionary in Liquid, other than having it returned from a filter or virtual member.

For dictionary objects, you can access values with a bracket syntax (using double quotes or single quotes).

context.SetValue("children", new Dictionary<string,string>() {
  { "oldest", "Alec" },
  { "middle", "Gabrielle" },
  { "youngest", "Isabella" }
{{ children["oldest"] }}

The dictionary keys can also be used directly as members:

{{ children.oldest }}

The first and last filters and virtual members don’t return anything for dictionaries, though size works as you would expect.

An invalid key won’t throw an error, it just won’t return anything.

All arrays can be iterated using a for loop (see Looping).

Finally, there is an entire set of filters for working with arrays which provide additional features, including the wrapping of several of C#'s native array and LINQ functions

This is item #7 in a sequence of 20 items.

You can use your left/right arrow keys to navigate