Freemarker - 将param传递给嵌套宏

时间:2012-10-29 20:10:04

标签: macros freemarker

假设我有两个宏,一个嵌套在另一个宏中。

[#macro testNestingTOP id]
   [#nested]
[/#macro]

[#macro testNesting]
   id: ${id}
[/#macro]

用法

如何从 testNesting 宏中检索id param的值?

[@testNestingTOP id='SOME VALUE']
  [@testNesting /]
[/@testNestingTOP]

1 个答案:

答案 0 :(得分:0)

将属性添加到内部宏并将id作为值传递给它

[@testNesting innerID ]
//code
[@testNesting /]

[@testNestingTOP id='SOME VALUE']
   //code
  [@testNesting innerID=id/]
  //code
[/@testNestingTOP]

我希望这可以帮助