Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Freemarker shortcut for boolean: "is not null and is true"

Tags:

freemarker

This seems to show "Hello world" if foobar is defined

<#if foobar??>
    Hello world
</#if>

If foobar is a boolean, what do I use to write Hello world if foobar is both defined AND true?

like image 877
Steve McLeod Avatar asked Oct 26 '25 08:10

Steve McLeod


1 Answers

The shortest I can think of is specifying a false default value:

<#if foobar!false>
    Hello world
</#if>
like image 128
ddekany Avatar answered Oct 29 '25 05:10

ddekany



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!