Question

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

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top