Question

I have a list map in freemarker and I want to check if "apple" or "mango" is one of the keys of this map , then do not display "id" & "class"

<#list listmap?keys as key> ${key} </#list>

So basically the above is my list map & I want to check if any of the keys in this map is either "apple" or "mango" i don't want to display "id" & "class". If there is no key named "apple" or "mango" then I want to display "id" & "class"

When I do this: The below is wrong because it's an iteration. I want to display nothing in fron of "id" & "class" when key is either "apple" or "mango". If there is no key as "apple" or "mango" I will display the value for "id" & "class" How do I do that? Should I use "contains" like Java? I'm not really sure of this

<#list listmap?keys as key >
<#if key == "apple" || key == "mango" && key?has_content>
setdisplay("id","");
setdisplay("class","");
<#else>
setdisplay("id","${getid}");
setdisplay("class","${getclass}");
</#if>
Was it helpful?

Solution

Something like:

<#if listmap.apple?? || listmap.mango??>
  setdisplay("id","");
  setdisplay("class","");
<#else>
  setdisplay("id","${getid}");
  setdisplay("class","${getclass}");
</#if>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top