Thursday, 29 August 2013

FreeMarker Reminders

A small post to aggregate notes related to FreeMarker.

Accessing Parameter Inside A Directive

The following piece of code:
    <#assign myVar = ${myValue}-1>
will trigger the following exception:
    Exception in thread "main" freemarker.core.ParseException:
      Encountered "{" ...
One should not use ${...} inside a FreeMarker directive, but rather:
    <#assign myVar = myValue - 1 >
See StackOverflow question.

How To Test A Boolean Value

This is how to test the enableAds boolean parameter value:
    <#if enableAds>
        ${AdsTopLeft}
    <#else>
        <img src="./incl/AdsSubstitute160-600.jpg">
    </#if>

Miscellaneous

Testing a value (if)Does a parameter/variable exist?

No comments:

Post a Comment