Freemarker: Most common expressions

This document will handle the most common expressions used by clients in RealTime Ads. It will be updated every time we find an expression that is commonly used. If you feel something is missing please send an e-mail to and I will add it to the document.




Replace more then one word:


Or if you are replacing a lot of words with the same word(in this example "this") you can use this code:

<#assign spel = title
?replace('med|for|if|lost, 'this', 'r')

Show how many products there are:


If title is less than or equal to 10 letters write "Come buy “title”":

  <#if title?length lte 10>

Come buy ${title}

Else if “title” is longer than 10 letters write "Buy hardware!" :

 <#if title?length lte 10>
Come buy ${title}
Buy hardware!

Find the cheapest product in the category:

<#assign cheapest = products[0]>

<#list products as product>
<#if product.priceWithTax ltcheapest.priceWithTax>
<#assign cheapest=product>


Only show ad groups with more then 5 articles in stock:

You put this as an "ad group should be active when" and set the "expression is true" and then use this code:

${(products?size > 5)?string}


Feedback and Knowledge Base