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 christopher.jundin@feedeo.com and I will add it to the document.

 

Replace:

${title?replace("here'","for")}


Replace more then one word:

${title?replace("med","for")?replace("this'","that")}

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:

${products?size}

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

  <#if title?length lte 10>

Come buy ${title}
</#if>

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

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

Find the cheapest product in the category:

<#assign cheapest = products[0]>

<#list products as product>
<#if product.priceWithTax ltcheapest.priceWithTax>
<#assign cheapest=product>
</#if>
</#list>
${cheapest.priceWithTax}

 

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