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

时间:2015-07-10 20:00:12

标签: freemarker

我试图使用行业列表来确定输出文本。例如,如果该行业是分销&批发或电子商务或制造业显示一些文本,否则显示一些其他文本。

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

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

然而,我似乎无法让它正常工作......有什么想法吗?

2 个答案:

答案 0 :(得分:0)

您可以这样做:

<#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>

答案 1 :(得分:0)

<#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")}