【问题标题】:Freemarker - pass param to nested macrosFreemarker - 将参数传递给嵌套宏
【发布时间】:2012-10-19 04:41:41
【问题描述】:

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

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

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

用法

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

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

【问题讨论】:

    标签: macros freemarker


    【解决方案1】:

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

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

    希望能帮到你

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-12-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-16
      • 2011-08-10
      • 1970-01-01
      相关资源
      最近更新 更多