| OLD | NEW |
| (Empty) |
| 1 <!-- | |
| 2 Copyright 2006 Google | |
| 3 Author: Steffen Meschkat (mesch@google.com) | |
| 4 Interactive jstemplates test page, specifically to demonstrate | |
| 5 recursive templates | |
| 6 | |
| 7 Modified slightly to work with compiled jstemplate file. | |
| 8 --> | |
| 9 <html> | |
| 10 <head> | |
| 11 <title>Interactive tests for jstemplate</title> | |
| 12 <script src="../jstemplate_compiled.js"></script> | |
| 13 <script src="jstemplate_script.js"></script> | |
| 14 <style> | |
| 15 .section { border: 1px solid silver; margin: 1em; } | |
| 16 .section TEXTAREA { border: none; width: 100%; } | |
| 17 </style> | |
| 18 </head> | |
| 19 <body onload="jsinit()"> | |
| 20 <table> | |
| 21 <tr> | |
| 22 <th>template</th> | |
| 23 <th>data</th> | |
| 24 </tr> | |
| 25 <tr> | |
| 26 <td> | |
| 27 <textarea id="template" rows="15" cols="80"></textarea> | |
| 28 </td> | |
| 29 <td> | |
| 30 <textarea id="js" rows="15" cols="80"> | |
| 31 { title: "title1", items: [ | |
| 32 { title: "title2", items: [ | |
| 33 { title: "title2", items: [ | |
| 34 { title: "title3", items: []}, | |
| 35 { title: "title4", items: []} | |
| 36 ]}, | |
| 37 { title: "title5", items: []} | |
| 38 ]}, | |
| 39 { title: "title3", items: []}, | |
| 40 { title: "title4", items: []}, | |
| 41 { title: "title5", items: []} | |
| 42 ], | |
| 43 testArray: ["", "", "1", "2"] | |
| 44 } | |
| 45 </textarea> | |
| 46 </td> | |
| 47 </tr> | |
| 48 <tr> | |
| 49 <td colspan="2"> | |
| 50 <a href="javascript:jstest(false)">process</a> | |
| 51 <a href="javascript:jstest(true)">reprocess</a> | |
| 52 </td> | |
| 53 </tr> | |
| 54 <tr> | |
| 55 <th>output HTML</th> | |
| 56 <th>output display</th> | |
| 57 </tr> | |
| 58 <tr> | |
| 59 <td> | |
| 60 <textarea id="html" rows="15" cols="80"></textarea> | |
| 61 </td> | |
| 62 <td> | |
| 63 <div id="out" class="section"></div> | |
| 64 </td> | |
| 65 </tr> | |
| 66 </table> | |
| 67 <p><a href="javascript:jstest(false)">Process</a> the | |
| 68 <b>template</b>, upper left, with the <b>data</b>, upper | |
| 69 right. See the resulting DOM in <b>output display</b>, lower | |
| 70 right, and the corresponding HTML text in <b>output HTML</b>, | |
| 71 lower left. Notice, however, that the template processing happens | |
| 72 directly on the HTML DOM, and the HTML text shown is merely the | |
| 73 <code>innerHTML</code> of that DOM.</p> | |
| 74 <p>Now, change the <b>data</b> and <a | |
| 75 href="javascript:jstest(true)">reprocess</a> the DOM of the <b>output | |
| 76 display</b> with the changed data, and see that the <b>output | |
| 77 display</b> reflects the change. Notice that the reprocessing | |
| 78 takes place on the DOM of <b>output display</b>, i.e. on the | |
| 79 result of the previous template processing.</p> | |
| 80 <div style="display:none" id="tc"> | |
| 81 <div id="t"> | |
| 82 <span jscontent="title"></span> | |
| 83 <ul jsdisplay="items.length"> | |
| 84 <li jsselect="items"> | |
| 85 <div transclude="t"></div> | |
| 86 </li> | |
| 87 </ul> | |
| 88 <div jsselect="testArray"> | |
| 89 content: <span jscontent="$this"></span> | |
| 90 </div> | |
| 91 </div> | |
| 92 </div> | |
| 93 </body> | |
| 94 </html> | |
| OLD | NEW |