【发布时间】: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