0

尝试使用 EL 生成一个将变量作为输入到布局宏 -> 参数 -> 表达式/文字的输入。但它不断给我编译错误或输入我的 EL 的文字。

目前有没有办法做到这一点?

layout-macro-def (game-details) {
  params {
    param (game) {
      type (Game)
      min (Required) max (One)
    }
  }
// [...]
        for-each (game.external_games) {
          as (item) {
            switch (item.category) {
              case (1) { // Steam
                layout-macro (UriButton) {
                  param (url) { // <<----- Expression for this is giving me issue
                    expression ("https://store.steampowered.com/app/#{value(item.uri)}")
                  }
                  param (image) {
                    literal (https://cdn.discordapp.com/attachments/354331388142419988/567499944391344158/unknown.png)
                  }
                  param (name) {
                    literal ("Steam")
                  }
                }
              }
// [...]

编辑添加的上下文

布局宏

layout-macro-def (UriButton) {
  params {
    param (url) {
      type (URL)
      min (Required)
    }
    param (image) {
      type (URL)
      min (Required) max (One)
    }
    param (name) {
      type (Name)
      min (Required) max (One)
    }
  }

  content {
    cell-card {
      on-click {
        intent {
          goal: UriRedirect
          value: UriRedirect {
            url {$expr(url)} // <--- Ultimate goal URL with URI appended to the end
            }
        }
      }
      slot1 {
        image {
          shape (Square)
          url ("#{value(image)}")
        }
      }
      slot2 {
        content {
          primary ("#{value(name)}")
        }
      }
    }
  }
}
4

1 回答 1

0

事实证明,您将模板放在预期表达式的位置。模板包含表达式(在 #{} 内),但它们本身不是表达式。

使用如下模板。

layout-macro (UriButton) {
  param (url) {
    dialog-template {
    template ("https://store.steampowered.com/app/#{value(item.uri)}")
  }
}
于 2019-04-16T18:17:03.740 回答