for loop with in the jsrender template

html, javascript, jquery, jsrender

Solution

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}}`.

Problem

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?

Original source