template.html 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <title></title>
  5. <meta charset="utf-8">
  6. </head>
  7. <body>
  8. <div id="hawaii" sd-template="test"></div>
  9. <script type="text/sd-template" sd-template-id="test">
  10. <p>{{hi}}!</p>
  11. </script>
  12. <script src="../dist/seed.js"></script>
  13. <script>
  14. // compile an existing node with sd-template directive
  15. // will replace its innerHTML with the template's content
  16. var hawaii = new seed.ViewModel({
  17. el: '#hawaii'
  18. })
  19. // if using template without an existing node
  20. // the VM's $el will be a clone of the template's content
  21. // and you will have to manually append it into DOM.
  22. // this is mostly to allow users to create VMs dynamically.
  23. var china = new seed.ViewModel({
  24. template: 'test'
  25. })
  26. document.body.appendChild(china.$el)
  27. hawaii.hi = 'Aloha'
  28. china.hi = '你好'
  29. </script>
  30. </body>
  31. </html>