views:

13

answers:

0

I'd like to use moustache.js to render the following JSON structure:

[
  {type:'img', src:'some_url'},
  {type:'text', text:'lorem ipsum ...'},
  {type:'link', href:'some_url', label:'click here'},
  //  more entries ...
]

I'd like to render each item depending on type: img should br rendered as <img src="{{src}}">, text as <p>{{text}}</p>, etc. Is that possible with moustache.js or should I roll my own templating system? If it's possible, how would the template look like and how must I extend the JSON structure that it works as a moustache view?