Reputation: 9033
I would like to check if a sequence is empty in a freemarker template.
This snippet works to check if a sequence contains a value:
<#if node.attachments?seq_contains("blue")>
<pre>hello</pre>
</#if>
However, if node.attachments
is empty i would like to do something else.
That is the syntax for this?
Upvotes: 36
Views: 37641
Reputation: 23
I suggest checking against size of zero. I do NOT suggest using ?has_content becasue of the following:
<#assign new_hash=[]>
Check if the hash has content:
<#if new_hash?has_content>
True - it is empty
<#else>
False - something is there
</#if>
Results in:
Check if the hash has content: False - something is there
Upvotes: 0
Reputation: 7204
Try:
<#if node.attachments?size != 0>
Or:
<#if node.attachments?has_content>
Upvotes: 67