LIQUID FOR TECHNICAL MARKETERS: Datatypes (String, Number, and Boolean)
🗣️ WATCH FULL YOUTUBE VIDEO HERE 🗣
What’s up everyone, my name is Allan, Founder and Consultant at For Now Marketing, and welcome to LIQUID FOR TECHNICAL MARKETERS!
If your goal is to improve your Liquid coding skills, then please
- like this video
- subscribe to our channel
- watch this video all the way to the end
- and keep an eye out for more videos in the future.
Today, we’re going to talk about 3 datatypes in Liquid: String, Number, and Boolean. Technically, there’s a few more datatypes, some which we will eventually discuss, and some which we won’t because they’re not as relevant for Braze Liquid. However, String, Number, and Boolean should cover 99% of our use cases.
We got a sneak peek into the datatypes in the previous video: for example, why was the variable value “allan” surrounded in quotes?
We’re about to find out; let’s get started!
String
The first and the main datatype is called a String.
Strings are sequences of characters wrapped in single or double quotes.
Characters, meaning they can be any letters, numbers, and symbols. So it really doesn’t matter what the value of the String is, but as long as it’s surrounded by quotes, that’s what makes the variable a String.
That explains why “allan” was surrounded in quotes, and because it’s surrounded in quotes, our variable “first underscore name” is a string variable.
By the way, single quotes and double quotes are pretty interchangeable in Liquid, as long as we stay consistent within a single tag. So we can use single quotes and this will render fine, we can use double quotes and this will render fine, but if we use one single quote and one double quote, this will not render.
Because Strings are so flexible and so many of the Liquid filters apply to Strings, majority of the variables we’ll work with, both in this class and most likely in your Marketing team’s database, will be a String variable.
Number
The next datatype is a Number. And a Number is simply… a Number. If we want to break it down further, there are integers which are 0, positive, and negative whole numbers, and there are floats, which are decimals. You may have also heard of doubles which are also decimals, very similar to floats.
To clarify, this is a different type of float than a root beer float.
The biggest thing to note is that Number datatypes are not surrounded by quotes. Remember, as soon as a variable is surrounded by quotes, even if the value itself is clearly a Number, the variable becomes a String. So if you’re trying to create a Number variable, make sure to not surround it in quotes.
Boolean
The last datatype is a Boolean.
Booleans are either true or false.
I’ve always thought Boolean was a very technical term that sounded funny, but a Boolean is literally just true or false. Those are the only two values a Boolean variable can have: true or false. So it’s actually the simplest datatype.
Once again, even with Booleans, make sure to not surround the values true or false with quotes, because then, they’ll be considered Strings.
One final note about Booleans: make sure to lowercase the Boolean values true or false, otherwise Liquid will not work properly.
Thank You!
Let’s wrap up this video with a sneak peek of the remaining datatypes. There’s a datatype called Nil which means the value does not exist. And in the context of Braze Liquid, Nil is actually different than blank. We’ll definitely talk more about this in the future.
There are also Arrays, which is a list of variables of the same datatype, and there are Objects, which is a group of variables, regardless of their datatype.
Thank you for watching, and see you next time!
allan@fornowmarketing.com
fornowmarketing.com