Reputation: 137
I want to make a list of filtered items in Netsuite HTML/email template. Seems that this line of code wont work on it using freemarker.
<#assign xs = [1, -2, 3, 4, -5]>
Positives:
<#list xs?filter(x -> x > 0) as x>${x} </#list>
Negatives:
<#list xs?filter(x -> x < 0) as x>${x} </#list>
Could you guys give me some insights on how to achieve this? Thank you so much in advance! I'm a beginner and been searching this a lot and unfortunately no luck at all.
Upvotes: 2
Views: 409
Reputation: 845
It looks like NetSuite is using FreeMarker v2.3.26 and the filter
built-in was added in 2.3.29.
Here's one way to do it without filter
:
<#assign xs = [1, -2, 3, 4, -5]>
<#assign xpos = []>
<#assign xneg = []>
<#list xs as x>
<#if x gt 0>
<#assign xpos = xpos + [x]>
<#elseif x lt 0>
<#assign xneg = xneg + [x]>
</#if>
</#list>
Positives:
<#list xpos as x>${x} </#list>
Negatives:
<#list xneg as x>${x} </#list>
Upvotes: 2