Call us toll-free @ 888-497-7898

Knowledge Base » Messages

Conditional Template Language

By Hypermail • Updated December 31, 2025 • 5 views

Our campaign system supports a powerful conditional template language, which works in both the HTML and text parts of your message. This language enables dynamic content generation based on if/elseif/else conditions, loops, and variables.

We support if/elseif/else and foreach, for, break, continue statements

Template Block Syntax:

  • Start statement: [#
  • End statement: #] Note: Always include a space after [ # and before # ] for correct parsing.

Variable Naming:
All variables start with a $ sign.

 

Setting Variables

You can assign variables within your template:

Sets data to number 5

[# $data = 5; #]

 

Built-in variables

All variables from the email list of the user is found in the $emailrow object.

Examples:

If your email list has the following columns

email,firstname,lastname,age

The email object would have the following variables.

$emailrow.email
$emailrow.firstname
$emailrow.lastname
$emailrow.age

We also automatically define each column in the list as its own variable so you also have access to the columns via their names

$email
$firstname
$lastname
$age

Again, remember the available variables are determined by your specific email list columns.

 

Last we have the system object

$system.date.monthname
$system.date.month
$system.date.day
$system.date.dayname like Monday Tuesday etc
$system.date.year
$system.date.time

Example: shows month name, day, year and time.
[# $system.date.monthname; #] [# echo $system.date.day; #], [# echo $system.date.year #]  [# echo $system.date.time #],

 

Check if a variable matches a value:
Checks if the list firstname variable equals john

[# if ($emailrow.firstname == "john") #]
Welcome back [# $emailrow.firstname #],
[# else #]

Welcome user,
[# endif #]

 

Using if/elseif/else for ranges:

[# if ($age >= 50) #]
Your insurance rate $1000 USD
[# elseif ($age >= 20) #]
Your insurance rate $500 USD
[# else #]
Your insurance rate $300 USD
[# endif #]

 

Iterate over all fields in $emailrow:

[# foreach($emailrow as $index => $tag) #]
[# $index #]. [# $tag #]

[# endforeach #]

 

 

For loop (counting 1 to 10):

[#for($i = 1; $i <= 10; $i++) #]    Count: [# $i #]
[# endfor #]

 

 

For loop with break and continue:

[# for($i = 1; $i <= 10; $i++) #]
    Count: [# $i #]
    [# if ($i == 5) #]
        We hit number 5!
        [# break #]
    [# endif #]
    [# if ($i == 4) #]
        [# continue #]
    [# endif #]
[# endfor #]





RSS/Atom Based Feeds
You can use <rsstitle> token in subject lines of email campaigns it will contain the first RSS feed title found! In your message.

RSSLIMIT= paramater sets how many entries to return

Example RSS fields:
{RSSFEED=https://rss.app/feeds/g1TDFhHyi5qilXLz.xml;RSSLIMIT=5}

[# foreach($rssitems as $index => $rss) #]
    [# $rss.title #] [# $rss.date #]
    [# $rss.description #]
    [# if ($rss.mediacontent != "") #]
        <img src="[# $rss.mediacontent #]" />
    [# endif #]
    [# if ($rss.link != "") #]
        Link: [# $rss.link #]
    [# endif #]
[# endforeach #]

 

Was this article helpful?

0 people found this helpful • 0 did not