no-escape.html 549 B

12345678910111213141516171819202122232425
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>no escape-demo</title>
  6. <script src="../dist/template.js"></script>
  7. </head>
  8. <body>
  9. <h1>不转义HTML</h1>
  10. <div id="content"></div>
  11. <script id="test" type="text/html">
  12. <p>不转义:{{#value}}</p>
  13. <p>默认转义: {{value}}</p>
  14. </script>
  15. <script>
  16. var data = {
  17. value: '<span style="color:#F00">hello world!</span>'
  18. };
  19. var html = template('test', data);
  20. document.getElementById('content').innerHTML = html;
  21. </script>
  22. </body>
  23. </html>