2014-02-11 43 views
0

我是freemarker的新手。我有類似$ {(pageData.author.name)!} &我試圖做類似瞭解freemarker插值

<#if ${(pageData.author.name)!}?has_content> 
      do something 
    </#if> 

    But this won't work as I can't put interpolations in the condition. How can I store   ${(pageData.author.name)!} in a variable named "var" & then check if var?has_content? 

我並不想從宏觀的價值。我想在本地存儲在本地變量

pageData.author.name值是freemarker的表達式 感謝

回答

2

只要寫:

<#if (pageData.author.name)?has_content> 

${...}構造僅使用其中的FreeMarker否則沒有按期待一個表達。 FreeMaker指令參數已經是表達式。這就像在<#if x * y == z>你有一個表達。

+0

酷讓你。非常感謝:D – user3298846