문제

I'm new to freemarker. I have something like ${(pageData.author.name)!} & I'm trying to do something like

   <#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? 

I don't want to get the value from macro. I want to store the value locally in a local variable

pageData.author.name is a freemarker expression Thanks

도움이 되었습니까?

해결책

Just write:

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

The ${...} construct is only used where FreeMarker otherwise doesn't expect an expression. FreeMaker directive parameters are already expressions. It's just like in <#if x * y == z> you have an expression.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top