views:

156

answers:

1

Hello everyone, i am trying to use mustache.js to render some JSON in the browser. What i want to do is:

<li>
   <span class="label">Location: </span> 
   {{#locations}}
     {{.}}<span class="social-small-size "></span>
   {{/locations}}
</li>

The locations is a js array

[["Pendéli, Attiki, Greece", "facebook"], ["Greece", "linkedin"]]

Initially i tried to use {{%IMPLICIT-ITERATOR iterator=loc}} in my attempt to split the data in the view. So i the actual rendering code was

{{loc[0]}}<span class="social-small-size {{loc[1}}"></span>

But that did n t work altough the loop worked and i got 2 spans but without any content. I think the PRAGMA is what I need but I didn 't figure it out. Any hints ? :)

A: 

The answer is quite simple, do not use arrays in array. You should uses hashes. The above code should work as

{{#locations}}
    {{value}} <span class='social-small-size {{network}}'></span>
{{/locations}}
PanosJee