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

This widget could not be displayed.

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
Posted Tuesday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

178 views 1 3
Join discussion

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