【问题标题】:Google Closure Templates variable variablesGoogle 闭包模板变量变量
【发布时间】:2017-10-17 16:41:52
【问题描述】:

情况:

context 包含 testExecutionKey1, testExecutionKey2 .. testExecutionKey10 等字段

我想检查它们是否为空,但这样做是个好方法 - 在 for 循环中

我需要在循环中访问 $context.testExecutionKey1..10,其中数字是 $i

{for $i in range(1, 11)}
    {if {$context.testExecutionKey}{$i}}
        <div class="aui-message aui-message-info">
            <p>A Test instance execution is already linked to this issue: <a href="$baseURL/browse/$context.testExecutionKey${$i}" target="_blank">${context.testExecutionKey{$i}}</a>.</p>
        </div>
        <input type="hidden" name="skip-test-execution-${$i}" value="true">
    {/if}
{/for}

问题:

PHP 具有可变变量功能,但我在文档中找不到类似的闭包模板。

【问题讨论】:

  • testExecutionKey1...testExecutionKey10 应该是一个数组
  • @T.J.克劳德 是的,抱歉,删除了 php 标签。不能是数组,因为 Jira 的 FormParameters 只能通过 String 键返回 String 值,所以这里没有其他选择,你有什么想法吗?
  • 这甚至是一个 JavaScript 问题吗?听起来这只是模板技术。如果是 JavaScript,答案应该是 $context['testExecutionKey' + $i] (see here),但是...

标签: web jira google-closure-templates soy-templates


【解决方案1】:

正确的方法是重新实现 jira 上下文

【讨论】:

  • 能否再次从标题中删除(已解决)?它并不是真正需要的,如果网站需要它,他们会自动添加它。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多