Guest User

Untitled

a guest
Mar 11th, 2013
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  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>
Add Comment
Please, Sign In to add comment