如何在 Freemarker 中使用字符串列表

How to use a list of strings in Freemarker

我正在尝试使用行业列表来确定输出文本。例如,如果行业是 Distribution & Wholesale OR eCommerce OR Manufacturing 显示一些文本,否则显示一些其他文本。

我在使用以下代码时遇到一些问题:

<#if (customer.custentity_esc_industry)=["Distribution \a Wholesale","eCommerce","Manufacturing"]>some text<#else>some other text</#if>

但是我似乎无法使其正常工作...有什么想法吗?

你可以这样做:

<#assign sequence = ["Distribution \a Wholesale","eCommerce","Manufacturing"] />
<#assign flag = 0 />
<#list sequence as seq>
     <#if customer.custentity_esc_industry == seq>
          <#assign flag =1>
          <#break />
     </#if>
</#list>
<#if flag == 1>
     //some text
<#else>
     //some other text
</#if>
<#if ["Distribution \a Wholesale", "eCommerce", "Manufacturing"]
         ?seq_contains(customer.custentity_esc_industry)>
  some text
<#else>
  some other text
</#if>

甚至(?then 需要 2.3.23):

${["Distribution \a Wholesale", "eCommerce", "Manufacturing"]
  ?seq_contains(customer.custentity_esc_industry)
  ?then("some text", "some other text")}