Mustache.js render technique

Posted by PanosJee on Stack Overflow See other posts from Stack Overflow or by PanosJee
Published on 2010-06-03T17:07:11Z Indexed on 2010/06/05 18:52 UTC
Read the original article Hit count: 602

Filed under:
|
|

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 ? :)

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about browser