default
如果存在就用本生的值,不存在就用缺省值
如果存在就用本生的值,不存在就用缺省值
<#assign seq = ['a', 'b']> ${seq[0]?default('-')} ${seq[1]?default('-')} ${seq[2]?default('-')} ${seq[3]?default('-')}
结果
a b - -
exists
It is true if the variable exists, otherwise it is false.
has_content
It is true if the variable exists and is not ``empty'', otherwise it is false. The meaning of ``empty'' depends on the concrete case.
expr?if_exists?size > 0 or expr?if_exists?length > 0 instead of expr?has_content.
if_exists
Example. Assume no variable called mouse is present:
(${mouse?if_exists}) Creating mouse... <#assign mouse = "Jerry"> (${mouse?if_exists})
The output will be:
() Creating mouse... (Jerry)