tags:

views:

54

answers:

1

In a freemarker template I want to expand a boolean variable to a string like that:

<#assign booleanVar = "test".isEmpty() />
state: ${booleanVar} <#-- this throws an exception! -->

This is what I want to get as output:

state: false

The only way I found to reach this goal by now is:

state: <#if booleanVar>true<#else>false</#if>

Is there a easier way to do it?

+1  A: 
booleanVar?string("true", "false")

Although true/false is default, so

booleanVar?string

should work fine.

tsilb
If I do this I get: "freemarker.core.InvalidReferenceException: Expression booleanVar$string is undefined".
tangens
I re-read that link... Changed the $ to ? in example. I don't know freemarker :)
tsilb