FreeMarker: Boolean Values Test

A simple test follows:

${message}

<#assign b=true>

Now perform scalar boolean tests:

<#if b> b is true.
<#else> b is false.

<#if false> This can't be!
<#else> This makes sense.

<#if boolean3> boolean3 succeeded.
<#else> boolean3 failed.

<#if boolean4> boolean4 succeeded.
<#else> boolean4 failed.

<#if boolean4 || boolean5> boolean4 || boolean5 succeeded.
<#else> boolean4 || boolean5 failed.

<#if boolean5 || boolean4 || boolean5> boolean5 || boolean4 || boolean5 succeeded.
<#else> boolean5 || boolean4 || boolean5 failed.

<#if boolean4 && boolean5> boolean4 && boolean5 succeeded.
<#else> boolean4 && boolean5 failed.

Now test list models:

<#if list1?exists> list1 succeeded.
<#else> list1 failed.

<#if list2?exists> list2 succeeded.
<#else> list2 failed.

Test hash models:

<#if hash1?exists> hash1 succeeded: ${hash1.temp}
<#else> hash1 failed: ${hash1.temp}

<#if hash2?exists> hash2 succeeded.
<#else> hash2 failed.

Test not operator:

<#if ! boolean1> Not boolean1 succeeded <#else> Not boolean1 failed

<#if !boolean1> Not boolean1 succeeded <#else> Not boolean1 failed

<#if ! boolean2> Not boolean2 succeeded <#else> Not boolean2 failed

<#if !boolean2> Not boolean2 succeeded <#else> Not boolean2 failed

<#if message == "Hello, world!"> Message is "Hello, world!" <#else> Message is something else (${message})

<#if message != "Hello, world!"> Message is not "Hello, world!" -- it's ${message} <#else> Message is "Hello, world!"