123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>parsing example</title>
- <script src="js-yaml-front-client.min.js"></script>
- <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
- <script>
-
- // to run example run gulp serve in root of project and visit locahost:3000
-
- var parsed;
- var text = "---\n"
- +"name: Derek Worthen\n"
- +"age: young\n"
- +"contact: \n"
- +" email: email@domain.com\n"
- +" address: some location\n"
- +"pets: \n"
- +" - cat\n"
- +" - dog\n"
- +" - bat\n"
- //+"match: !!js/regexp /pattern/gim"
- //+"run: !!js/function function() { }"
- +"---\n"
- +"Some Other content\n";
- $(function() {
- $('#input').text(text);
- $('#parse').click(function(e) {
- e.preventDefault();
- var toParse = $('#input').text();
- parsed = jsyaml.loadFront(toParse);
- console.log(parsed);
- $('#output').text(JSON.stringify(parsed));
- });
- });
- </script>
- </head>
- <body>
- <textarea id="input" rows="40" cols="75"></textarea>
- <textarea id="output" rows="40" cols="75"></textarea>
- <button id="parse">Parse</button>
- </body>
- </html>
|