]> Dogcows Code - chaz/p5-CGI-Ex/blob - samples/yaml_js_2.html
CGI::Ex 2.00
[chaz/p5-CGI-Ex] / samples / yaml_js_2.html
1 <html>
2 <title>Yaml Test</title>
3 <body>
4
5 <table border=1 cellspacing=0>
6 <tr>
7 <td colspan=2>
8 <script src="../lib/CGI/Ex/yaml_load.js"></script>
9 <script>
10
11 if (! document.yaml_load) {
12 document.writeln('<span style="color:red"><h1>Missing document.yaml_load</h1>Path to ../lib/CGI/Ex/yaml_load.js may be invalid.</span>');
13 } else {
14 document.writeln('<span style="color:green"><h1>Found document.yaml_load</h1></span>');
15 }
16
17 </script>
18 </td>
19 </tr>
20
21 <tr><th colspan=2>YAML text</th></tr>
22 <tr>
23 <td colspan=2>
24 <pre><script>
25 var yaml = "--- #YAML:1.0\n\
26 - foo1: bar1\n\
27 foo2: {key1: val1, key2: 'value 2'}\n\
28 foo3:\n\
29 - a\n\
30 - list\n\
31 - of\n\
32 - items\n\
33 - 'with the last item being a long string'\n\
34 foo4: [another, list, of, values]\n\
35 foo5a: |\n\
36 A block of text\n\
37 that is on multiple lines.\n\
38 foo5b: |+\n\
39 A block\n\
40 of text\n\
41 that is on\n\
42 multiple lines.\n\
43 foo6a: >\n\
44 A block\n\
45 of text\n\
46 that is on\n\
47 multiple lines and is folded.\n\
48 foo6b: >+\n\
49 A block\n\
50 of text\n\
51 that is on\n\
52 multiple lines and is folded.\n\
53 foo7: 'singlequoted''with embedded quote'\n\
54 foo8: \"doublequoted\\\"with embedded quote\"\n\
55 ";
56 //"
57 document.write(yaml)
58 </script></pre>
59 </td>
60 </tr>
61
62
63 <tr>
64 <th>Produces</th><th>Should look like</th>
65 </tr>
66 <tr>
67 <td>
68 <pre><script>
69 var t1 = new Date();
70 var y = document.yaml_load(yaml)
71 var t2 = new Date();
72 document.write(document.js_dump(y));
73 </script></pre>
74 </td>
75 <td>
76 <pre>Dump:
77 [obj].0.0.foo1=bar1
78 [obj].0.0.foo2.key1=val1
79 [obj].0.0.foo2.key2=value 2
80 [obj].0.0.foo3.0=a
81 [obj].0.0.foo3.1=list
82 [obj].0.0.foo3.2=of
83 [obj].0.0.foo3.3=items
84 [obj].0.0.foo3.4=with the last item being a long string
85 [obj].0.0.foo4.0=another
86 [obj].0.0.foo4.1=list
87 [obj].0.0.foo4.2=of
88 [obj].0.0.foo4.3=values
89 [obj].0.0.foo5a=A block of text
90 that is on multiple lines.
91 [obj].0.0.foo5b=A block
92 of text
93 that is on
94 multiple lines.
95
96 [obj].0.0.foo6a=A block of text that is on multiple lines and is folded.
97 [obj].0.0.foo6b=A block of text that is on multiple lines and is folded.
98
99 [obj].0.0.foo7=singlequoted'with embedded quote
100 [obj].0.0.foo8=doublequoted"with embedded quote
101 </pre>
102 </td>
103 </tr>
104
105 <tr>
106 <td colspan=2>
107 <script>
108 document.write("Elapsed time: "+((t2.getTime() - t1.getTime())/1000)+" seconds");
109 </script>
110 </td>
111 </tr>
112
113 </body>
114 </html>
This page took 0.033286 seconds and 4 git commands to generate.