how do i loop Soy templates with data as array passed to template

GopiR June 13, 2016

Js code

exampleArray = [project1,project2];

var templateproject = JIRA.Templates.LP.project(exampleArray);

AJS.$('#page-container').append(templateproject);

 

soy template

{namespace JIRA.Templates.LP}
{template .project}
<table class="aui">
<thead>
<th>Project Title</th>
</thead>
<tbody>
{foreach $key in keys($exampleArray)}
<tr>
<td>{$exampleArray[$key]}</td>
</tr>
{/foreach}
</tbody>
</table>
{/template}

 

Is this correct way of looping soy template when passing array as data.

 

 

 

1 answer

2 votes
Petar Petrov (Appfire)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 13, 2016

You can also do:

{foreach $project in $exampleArray}
&lt;tr&gt;
&lt;td&gt;{$project}&lt;/td&gt;
&lt;/tr&gt;
{/foreach}

Suggest an answer

Log in or Sign up to answer