简体   繁体   中英

How can I create a condition where a command is executed if my string length is more than one character using Freemarker?

I would like to create a condition where if my string is more than one character a command is executed. I think my format is incorrect. I am using the following code:

                <#list kirt as x>
                  <#if x.length >1>
                    ${x}<#if x_has_next>,</#if>
                  </#if>
               </#list>

But I keep getting this error:

Exception when trying to transform with the FTL template! freemarker.core.NonHashException: For "." left-hand operand: Expected a hash, but this evaluated to a string (wrapper: ftSimpleScalar): ==> x [in template "core/webinars/gmlwebinar.ftl" at line 119, column 36] ---- FTL stack trace ("~" means nesting-related): - Failed at: #if x.length [in template "core/webinars/gmlwebinar.ftl" at line 119, column 31] ----

I'm not sure what the problem is

Like this:

<#if x?length gt 1>

because:

  • FTL normally doesn't expose methods for which there's an ?something thing
  • The > would close the tag

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM