你如何在FreeMarker宏中调用函数?

时间:2017-02-13 22:04:25

标签: freemarker

有没有办法在Freemarker宏中调用函数? 我想要做的例子:

<#function foo>
  <return "hello">
</#function>

<#macro fooMacro>
  ${foo()}    
</#macro>

<@fooMacro> <#-- This doesn't work for me
                 "The "foo()" has evaluated to null or missing" -->

同样,有没有办法将函数的输出传递给宏的参数?像:

<#macro fooMacro p1>
   ${p1}
</#macro>

<@fooMacro p1=foo()/> <!-- Also doesn't seem to work for me -->

1 个答案:

答案 0 :(得分:0)

答案:两者都有可能,只需更改

<return "hello">  ==>  <#return "hello">