Skip to main content

Using Liquid Syntax in Woodpecker

Written by Weronika Wróblewska

IN THIS ARTICLE:


What is Liquid Syntax

Liquid Syntax is a powerful templating language that can be used to create dynamic content for your email using prospects’ data. It is simple to learn and use, making it a great choice for users who need to quickly create highly personalized emails.


Before diving into templates, here are some basics about the model used in Woodpecker Liquid Syntax:

You can enter any variable into the template and assign it a value. The name of the variable should start with the $ character. A valid identifier consists of lowercase or uppercase letters, numbers, and the _ character, but must begin with the letter.

Examples of such formats:

  • $variable

  • $myVariable123

  • $my_variable

To define variables, look at the examples of doing so:

  • #set ($foo = "first name") - the variable is a word

  • #set ($foo = 1) - the variable is a number

  • #set ($use_liquid = true) - the variable matches the snippet used later in the template

In order for liquid syntax to work properly in a template, you have to use at least one of the following directives: #set or #if.

The #set directive lets you specify the value for a variable. For example, if you want to use $current_hour in the email copy, you need to specify the source of that value.

So if you write:

#set ($current_date = $date.get('yyyy'))

The $current_date in your email copy will be replaced with the value specified there. In this case, it would be replaced with the current year.

The #if directive allows for text to be included when the email is being generated and sent out on the conditional that the if statement is true. If you want to set up content for the situation if the statement is false, use the #else of #elseif element.

Operators that you can use in conditional statements are listed in the table below.

Operator Name

Symbol

Alternative Symbol

Example

Equals Number

==

eq

#if( $foo == 42 )

Equals String

==

eq

#if( $foo == "bar" )

Object Equivalence

==

eq

#if( $foo == $bar )

Not Equals

!=

ne

#if( $foo != $bar )

Greater Than

>

gt

#if( $foo > 42 )

Less Than

<

lt

#if( $foo < 42 )

Greater Than or Equal To

>=

ge

#if( $foo >= 42 )

Less Than or Equal To

<=

le

#if( $foo <= 42 )

Boolean NOT

!

not

#if( !$foo )


Template examples

When using Liquid Syntax in Woodpecker, you have to write a template in the campaign editor (in the Text mode). To check the result, click on the “Preview” button in the campaign summary. If an error occurs, you’ll be notified about it, and you won’t be able to run the campaign until the template is correct.

The list of variables that you can use in the template without defining is all the snippets used in Woodpecker. Keep in mind that only the original snippet names are taken into account - snippet labels will not be detected correctly.

a) Personalized greetings

You can adjust greetings based on gender:

#if ($SNIPPET_1 == "female")
Dear Mrs. {{FIRST_NAME}}
#else
Dear Mr. {{FIRST_NAME}}
#end

Example result:


b )Time-zone based greetings

Liquid Syntax uses our server time (Poland timezone). If you want to include a greeting that varies depending on the time of day, you can enter the template like this:

#set ($current_hour = $date.get('HH'))
#if ($current_hour < 12) Good Morning!
#elseif ($current_hour < 18) Good Afternoon!
#else Good evening!
#end

Liquid Syntax in the preview:


c) Dates and hours

If you want to include the current date or specific hour in the content of your email, you’ll need to add the following code:

#set ($current_hour = $date.get('HH'))

That can then be used in the copy of your email like this:

The correct formatting for dates is: yyyy-M-d HH:mm:ss.

There are also options for more detailed date description/writing, which must be defined as a separate variable.

Examples of formatting the “current” date:

$date

Feb 4, 2025 9:54:50 PM

$date.long

February 4, 2025 9:54:50 PM PDT

$date.medium_time

9:54:50 PM

$date.full_date

Tuesday, February 4, 2025

$date.get('default','short')

Feb 4, 2025 9:54 PM

$date.get('yyyy-M-d H:m:s')

2025-02-04 21:54:50

$date.iso

2025-02-04T21:54:50-07:00

$date.iso_tz_time

21:54:50-07:00

$date.intl_tz

2025-02-04 21:54:50 CET

It can be used like this:

#set ($current_date = $date)
Today is $current_date, and I am writing to you regarding....

You can assemble any format using the examples of formatting above. If you want the day and hour to be shown in an email, you can write it as:

#set ($current_date = $date.get('d HH'))

d) Condition in a campaign

You can substitute creating a condition in a Woodpecker campaign with creating two paths by using a template like this:

#if( $SNIPPET_1 == "Mr" )

...content for YES path...

#else

...content for NO path...

#end

e) Replacing custom snippets and snippet fallbacks

To stick with Liquid Syntax format in your email copy, you can substitute Woodpecker system’s format, so instead of:

Hello {{FIRST_NAME}}

It’s this, with the defined variable for the first name snippet:

#set ($foo = "FIRST_NAME")
Hello $FIRST_NAME

For snippet fallbacks, it’s similar to setting a condition. Instead of:

Hello {{FIRST_NAME | "there"}}

You can use a template like this:

Hello #if ($FIRST_NAME) $FIRST_NAME
#else there
#end

For snippet fallbacks, it’s similar to setting a condition. Instead of:

Hello {{FIRST_NAME | "there"}}

You can use a template like this:

Hello #if ($FIRST_NAME) $FIRST_NAME
#else there
#end

Or even simpler format:

#set ($use_liquid = true)
Hello ${FIRST_NAME|'there'}

The #set directive here is used to meet the requirements of Liquid Syntax.


Here are a few things to remember when using Liquid Syntax in Woodpecker:

  • Verify if the format is correct.

  • Ensure the variables in your template match those in your prospects' database.

  • Use the “Preview” mode to check your syntax result before running the campaign.


FAQ

Q.: Can I use the correct year, month, or hour in any timezone?

Right now, it’s not implemented in Woodpecker, but we are working on introducing it.

Q.: Can I use Spintax with this method?

The only templates supported right now are described in this article. Spintax is not yet implemented with Liquid Syntax in Woodpecker.

Did this answer your question?