Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Testing variable of boolean type in Freemarker

The isOffline field in my websetting object is a boolean type. In my Freemarker template, I need to check if it's true of false.

So I did the following, but it does not work

<#if !websetting.isOffline> false </#if>

It looks like Freemarker does not support the Not !. I've also tried <#if websetting.isOffline == false> false </#if>, but it's not working.

like image 709
TonyGW Avatar asked Jun 20 '14 21:06

TonyGW


1 Answers

The isOffline isn't the best name for a boolean property because the default getter method for it is also isOffline.

If you cannot change the name of the property then show that you want to call method in template with ().

<#if !websetting.isOffline()> false </#if>

But it is better to change name to something w/o is in front of it (e.g. to offline). Then you can use it in template.

<#if !websetting.offline> false </#if>
like image 126
Aleksandr M Avatar answered Oct 09 '22 20:10

Aleksandr M