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

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

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
Community showcase
Asked Thursday in Jira Ops

I'm John Allspaw, Ask Me Anything about incident analysis and postmortems

I'm John Allspaw, co-founder of   Adaptive Capacity Labs, where we help teams use their incidents to learn and improve. We bring research-driven methods and approaches to drive effective inciden...

446 views 2 5
View question

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you