Tuesday, January 11, 2022

FTL template - Cheatsheet

 This is a short documentation on how to use FTL template (FreeMarker Template Language)

https://freemarker.apache.org/


To try your Freemarker template online, use this interactive tool:

https://try.freemarker.apache.org/


How to check string not blank in FTL?

<#if myVariable.name?has_content>

How to null check in FTL?

<#if myVariable.name??>

How to import another FTL file?

<#import "/partials/my-partial-form.ftl" as partial>

How to call a macro in a partial form in FTL?

<@partial.myMacro myParam1 = 123/>

How to print timestamp as ISO string in FTL?

${myVariable.timestamp?datetime?string.iso}

${myVariable.timestamp?datetime?string.iso}

How to trim string in FTL?

${envelope.customer.lastName?trim}

How to keep 1 digital after decimal point in FTL?

#{y; m1}