Liquid Datatypes
Liquid objects can produce one of six types: String, Number, Boolean, Nil, Array, or EmptyDrop. Liquid variables are set up using the assign
or capture
tags.
Strings
Strings in programming are marked by enclosing the value of a variable inside either single (' ') or double (" ") quotes.
{{ my_string }}
Numbers
Numbers include floats and integers.
{{ my_num }}
Booleans
Booleans represent values that can be either true or false. When declaring a boolean variable, you do not use quotation marks.
{%- assign bar = false -%}
Nil
Nil represents an absence of value returned by Liquid code when there are no results. It's distinct from a string containing the characters 'nil'. In {% if %}
blocks and similar Liquid tags, Nil behaves like false when evaluating conditions.
Note: A string containing the characters "nil" is different from the value nil.
Arrays
Arrays contain a collection of variables of various types. To retrieve elements from an array, you can iterate through each item using a for
tag or a tablerow
tag.
{{ tag }}
{%- endfor -%}
EmptyDrop
An EmptyDrop object is returned when attempting to access an object that does not exist. This could happen if a collection, page, or blog has been deleted or hidden.
<h1>{{ page.title }} </h1>
<div>
{{ page.content }}
</div>
{%- endunless -%}