Data types
Last updated
Was this helpful?
Last updated
Was this helpful?
In Liquid, different kinds of data have different types. Each type describes the nature of its data.
Some of the documentation below is specific to Mechanic Liquid, and may not apply to Shopify Liquid, or to other Liquid implementations.
A string contains a series of characters, forming text.
Liquid supports both two number types: integers (whole numbers) and floats (numbers having decimal precision).
Borrowing from , Liquid's nil
is an empty value that is returned when Liquid code has no results. It evaluates to false
in conditionals statements, and outputs nothing when printing out text.
If a variable reference comes up missing, Liquid will silently use nil
instead without raising an error.
An array is a value that itself contains an ordered list of other values. Each value has an index, representing the order in which each value occurs in the list.
All of the following examples return the same value.
In Mechanic, a hash is a simple type of object that has no additional intelligence at all; it only contains keys and values. It can be constructed by the developer using code.
Liquid supports creating arrays of strings using the filter. In Mechanic, arrays can be created using the .
Mechanic includes a variety of , useful for transforming arrays or retrieving specific values.
An object is any value that has attributes (also known as properties). The name of an attribute is known as its key; the data stored for an attribute is known as its value. In Mechanic, some objects have additional intelligence of their own, like the .
Objects may be traversed using .
In Mechanic, hashes can be created using the literal, or by using any of the "parse" .
Hashes may be traversed using , like other objects. For convenience, Mechanic also supports extract an array of hash keys using the filter, or object values using the filter. The resulting arrays may also be used with a for loop, like any array.