API / Apache FreeMarker Interview questions
What is the purpose of the <#if> directive?
<#if> lets a template branch its output based on a boolean condition, the same role an if-statement plays in a programming language. It supports <#elseif> for additional conditions and <#else> for a fallback, and must always be closed with </#if>.
<#if user.role == "ADMIN"> Welcome, administrator. <#elseif user.role == "EDITOR"> Welcome, editor. <#else> Welcome, guest. </#if>
Conditions can use comparison operators, boolean logic (&&, ||, !), and the existence-test operator ?? to safely check whether a variable is present before comparing it.
More Related questions...