布尔值的 Freemarker 快捷方式:"is not null and is true"
Freemarker shortcut for boolean: "is not null and is true"
这似乎表明 "Hello world" 如果定义了 foobar
<#if foobar??>
Hello world
</#if>
如果 foobar 是布尔值,如果 foobar 既已定义又为真,我该如何编写 Hello world?
我能想到的最短的是指定一个 false
默认值:
<#if foobar!false>
Hello world
</#if>
这会起作用:
<#if foobar??>
<#if foobar?is_string>
Hello world
</#if>
</#if>
这似乎表明 "Hello world" 如果定义了 foobar
<#if foobar??>
Hello world
</#if>
如果 foobar 是布尔值,如果 foobar 既已定义又为真,我该如何编写 Hello world?
我能想到的最短的是指定一个 false
默认值:
<#if foobar!false>
Hello world
</#if>
这会起作用:
<#if foobar??>
<#if foobar?is_string>
Hello world
</#if>
</#if>