index.html 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>parsing example</title>
  6. <script src="js-yaml-front-client.min.js"></script>
  7. <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
  8. <script>
  9. // to run example run gulp serve in root of project and visit locahost:3000
  10. var parsed;
  11. var text = "---\n"
  12. +"name: Derek Worthen\n"
  13. +"age: young\n"
  14. +"contact: \n"
  15. +" email: email@domain.com\n"
  16. +" address: some location\n"
  17. +"pets: \n"
  18. +" - cat\n"
  19. +" - dog\n"
  20. +" - bat\n"
  21. //+"match: !!js/regexp /pattern/gim"
  22. //+"run: !!js/function function() { }"
  23. +"---\n"
  24. +"Some Other content\n";
  25. $(function() {
  26. $('#input').text(text);
  27. $('#parse').click(function(e) {
  28. e.preventDefault();
  29. var toParse = $('#input').text();
  30. parsed = jsyaml.loadFront(toParse);
  31. console.log(parsed);
  32. $('#output').text(JSON.stringify(parsed));
  33. });
  34. });
  35. </script>
  36. </head>
  37. <body>
  38. <textarea id="input" rows="40" cols="75"></textarea>
  39. <textarea id="output" rows="40" cols="75"></textarea>
  40. <button id="parse">Parse</button>
  41. </body>
  42. </html>