I am trying to create a FreeMarker macro that can return the interpolation of a concatenation of a string and the input variable:
<#macro findValue var>
<#if (.vars["foo." + var]) ??>
.vars["foo." + var]
<#else>
${.vars["bar." + var]}
</#if>
</#macro>
Unfortunately it doesn't work. Firstly, ${.vars["bar." + var]}
gives an undefined
error. Secondly, the if
condition always returns false
even when I can see that the sub variable do exist. It seems like the .vars
variable can only look up root variables, but not sub variables like foo.test
.