for loop with in the jsrender template

Raja picture Raja · Jan 9, 2014 · Viewed 8.6k times · Source

In my working scenario i am using the following code snippet with in the js render template:

{{:#data['" + columnName + "']}} 

and this will return the value as:

[object Object],[object Object]

How to get a specific property from this array object [object Object],[object Object] within the js render template using a for loop?

Answer

Dave Ward picture Dave Ward · Jan 10, 2014

You can use {{for}} to iterate over an array. Something like this:

<ul>
{{for columnName}}
  <li>{{:Property}}</li>
{{/for}}
</ul>

Inside the loop, your base scope automatically becomes that particular object in the array, so you can output any of the object's properties directly with {{:Property}}.