I’m working with FreeMarker templates and encountering an issue related to comparing variables. My template code is as follows:
<#function getDataType column>
<#if utils.isEnumeration(column.dataType, column.isEnum)>
<#assign similarColumnsSize = data.columns?filter(col -> col.dataType == column.dataType)?size>
<#if similarColumnsSize gt 2> <---- FAILS HERE
${column.dataType}Test
<#else >
${column.dataType}
</#if>
<#else>
${utils.getCassandraJavaDataType(column.dataType)}
</#if>
</#function>
When I run this template, I get the following error:
FreeMarker template error:
Can't convert boolean to string automatically, because the "boolean_format" setting was "true,false", which is the legacy deprecated default, and we treat it as if no format was set. This is the default configuration; you should provide the format explicitly for each place where you print a boolean.
----
Tip: Write something like myBool?string('yes', 'no') to specify boolean formatting in place.
----
Tip: If you want "true"/"false" result as you are generating computer-language output (not for direct human consumption), then use "?c", like ${myBool?c}. (If you always generate computer-language output, then it's might be reasonable to set the "boolean_format" setting to "c" instead.)
----
Tip: If you need the same two values on most places, the programmers can set the "boolean_format" setting to something like "yes,no". However, then it will be easy to unwillingly format booleans like that.
----
----
FTL stack trace ("~" means nesting-related):
- Failed at: ${getDataType(column)} [in template "common/entityColumnDelta.ftl" at line 5, column 11]
- Reached through: #include "/common/entityColumnDelta.ftl" [in template "dao/entity/entity.ftl" at line 24, column 1]
----
Any insights on how to properly handle boolean values in this context would be greatly appreciated.