API / Apache FreeMarker Interview questions
How do you use the #assign directive?
<#assign name=value> creates or overwrites a variable in the current namespace so it can be reused later in the template.
<#assign fullName = user.firstName + " " + user.lastName> Hello, ${fullName}!
It can also assign a captured block of markup rather than a simple expression, using the tag-body form:
<#assign greeting> Hello, ${user.firstName}! </#assign>
Used at the top level of a template, #assign creates a variable in that template's namespace; used inside a macro without #local, it still targets the enclosing namespace, not a variable private to the macro call.
More Related questions...