Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Mar 11th, 2013  |  syntax: None  |  size: 0.92 KB  |  views: 19  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <div id="output"></div>
  2.  
  3. <script id="template" type="text/x-jsrender">
  4. <ul>
  5.     {{for}}
  6.     <li>{{:name}} likes to wear {{:shirtColor}} shirts</li>
  7.     {{/for}}        
  8. </ul>
  9. </script>​
  10.        
  11. var data = [{
  12.     name: 'Dan Wahlin',
  13.     shirtColor: 'white'},
  14. {
  15.     name: 'John Papa',
  16.     shirtColor: 'black'},
  17. {
  18.     name: 'Scott Guthrie',
  19.     shirtColor: 'red'}
  20. ]
  21. ;
  22.  
  23. $('#output').html($('#template').render(data));​
  24.        
  25. var data = { people: [{
  26.     name: 'Dan Wahlin',
  27.     shirtColor: 'white'},
  28. {
  29.     name: 'John Papa',
  30.     shirtColor: 'black'},
  31. {
  32.     name: 'Scott Guthrie',
  33.     shirtColor: 'red'}
  34. ]
  35. }
  36. ;
  37.        
  38. <ul id="output"></ul>
  39. <script id="template" type="text/x-jsrender">
  40.     <li>{{:name}} likes to wear {{:shirtColor}} shirts</li>
  41. </script>​
  42.        
  43. <script id="template" type="text/x-jsrender">
  44.     <ul>
  45.         {{for #data}}
  46.             <li>{{>name}} likes to wear {{>shirtColor}} shirts</li>
  47.         {{/for}}
  48.     </ul>
  49. </script>
clone this paste RAW Paste Data