参数未传递给 layout-macro-def

Parameter not being passed to layout-macro-def

似乎没有将参数传递给布局宏定义,我不明白为什么。

我已阅读布局/布局宏的文档。

在我的布局中,我有这样的东西:

result-view {
  match:  dailyDeals (this) {
    from-property: inventory (inventory) // the param to pass
  }
  message {
    template  ("Wow!") {
      speech ("#{value(this)}")
    }
  }
  render {
    layout {
      section {
      ....
      value ("#{value(inventory.item)}" // e.g., a vbox text value
      ....
      layout-macro (myMacro) {param (inventory)}
      }
    }
  }
}

我有一个这样的布局宏:

layout-macro-def (myMacro) {
  params {
    param (inventory) {
      type (inventory)
      max (Many) 

    }
  }
  content {
    ....
    value ("#{value(inventory.item)}" // e.g., a vbox text value
    .....
   }
}

我可以从布局中访问 inventory 值(例如,inventory.item)到宏,因为 inventory.item 不会出现在 myMacro 的布局中。

我错过了什么?

我认为您需要将表达式键添加到参数中。 试试这个:

 render {
    layout {
      section {
      ....
      value ("#{value(inventory.item)}" // e.g., a vbox text value
      ....
      layout-macro (myMacro) {param (inventory) {expression (inventory)} }
      }
    }
  }