Skip to content

Freemarker tips

Per Nyfelt edited this page May 6, 2024 · 3 revisions

Freemarker tips

Accessing static methods

In order for freemarker to understand what static class you are referring to, you need to declare it using the #assign tag. If we want to use LocalDate for instance you declare it as follows (e.g. in the header section):

<#assign LocalDate=statics['java.time.LocalDate'] />

and the you can use it as you would expect e.g:

<div>Date: ${LocalDate.now()}</div>

Note: This functionality is available from version 0.6.2. It is made possible by a BeanWrapper added as a global, shared variable with the name 'statics' to the Freemarker configuration.

Clone this wiki locally