Freemarker notes

  • Built-in Function

Built-ins are like methods that are added to the objects by FreeMarker. To prevent name clashes with actual methods and other sub-variables, instead of dot (.), you separate them from the parent object with question mark (?).

Some examples:

${testString?upper_case}
${testString?html}
${testString?upper_case?html}

${testSequence?size}
${testSequence?join(", ")}

Assuming that testString stores the string “Tom & Jerry”, and testSequnce stores the strings “foo”, “bar” and “baz”, the output will be:

TOM & JERRY
Tom & Jerry
TOM & JERRY

3
foo, bar, baz

html(deprecated): This built-in is deprecated by the auto-escaping mechanism introduced in 2.3.24.

Other examples:

path?ensure_starts_with('/')
path?length
<#--not path?length()-->

Ref links: builtin methods