Understand the types of data
So far, we have mentioned two data types, strings and numbers to be precise. However, in Liquid, there are six different types of data that are available to us:
- Strings
- Number
- Boolean
- Nil
- Array
- EmptyDrop
Strings
A string is a type of data that we use to represent text. Since a string can be any combination of letters, numbers, or special characters, we should always encapsulate it with quotation marks:
{% if product.title contains "Book" or product.title contains "2021" %} We have found a product that contains the word Book or the product that contains the word 2021. {% endif %}
In the previous example, we check whether the product title contains the string "Book"
or the same product title contains the string "2021"
, and if it does, our message will be shown.
Number
A number is a type of data that require no quotation marks, and...