requirejs-html-beautify.html 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <!doctype html>
  2. <html lang="en-US">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title></title>
  6. <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/require.js/2.1.10/require.min.js"></script>
  7. <script type="text/javascript">
  8. require(["../lib/beautify-html"],function(html_beautify){
  9. var input = document.getElementById("input").value;
  10. var output = html_beautify.html_beautify(input);
  11. document.getElementById("output").innerHTML = output;
  12. });
  13. </script>
  14. <style type="text/css">
  15. #output{
  16. border: 1px solid black;
  17. height: 300px;
  18. width: 100%;
  19. }
  20. #input{
  21. width: 100%;
  22. height: 300px;
  23. }
  24. </style>
  25. </head>
  26. <body>
  27. <h1>RequireJS test</h1>
  28. <p>
  29. This example loads the html-beautifier by using a relative path in the require call to the beautify-html.js file.
  30. (also works works with absolute paths)
  31. </p>
  32. <pre>
  33. require(["../lib/beautify-html"],function(html_beautify){
  34. var input = document.getElementById("input").value;
  35. var output = html_beautify.html_beautify(input);
  36. document.getElementById("output").innerHTML = output;
  37. });
  38. </pre>
  39. <h2>Input</h2>
  40. <textarea name="" id="input">
  41. <ul><li><a href="test"></a></li></ul>
  42. </textarea>
  43. <h2>Output</h2>
  44. <textarea name="" id="output">
  45. </textarea>
  46. </body>
  47. </html>