Assigning a variable
Variables output values in your snippets. Variable names are denoted by double curly braces:
}}. To render the content of a variable called
title with the value
You can initialize variables with the
Creates a new variable.
Captures the string inside of the opening and closing tags and assigns it to a variable. Variables created through
capture are strings.
There are five variable types: string, number, boolean,
nil, and array.
Declare a string by wrapping a variable’s value in single (
') or double quotes (
Numbers include floats and integers:
Booleans are either
false. No quotations are necessary when declaring a boolean:
nil is a special empty value that is returned when we have no results. It is not a string with the characters “nil”.
nil is treated as
false in the conditions of
if blocks and other tags that check the truthfulness of a statement.
Tags or outputs that return
nil will not print anything to the page.
Arrays hold lists of variables of any type. You can use square bracket
[ ] notation to access a specific item in an array, and array indexing starts at zero.
You cannot initialize arrays. You can, however, use the
split filter to break a string into an array of substrings.
Truthy and falsey
Anything that returns
true in a conditional is called truthy. Anything that returns
false in a conditional is called falsy. All variables can be described as either truthy or falsy.
All values are truthy except
false, even empty strings, arrays, and zero.
|empty string (i.e.,
|non-zero integer (e.g.,
|non-zero float (e.g.,
|empty array (e.g.,
Find a typo? Something is wrong in this documentation? Fork and edit it!