Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / third_party / jstemplate / tutorial_examples / 08-transclude.html
blobebab76fb3864fba5559e90b9a02385efafe7b88c
1 <html>
2 <head><title>Outline Tree Using Jstemplates</title>
3 <script src="../util.js" type="text/javascript"></script>
4 <script src="../jsevalcontext.js" type="text/javascript"></script>
5 <script src="../jstemplate.js" type="text/javascript"></script>
6 <script type="text/javascript">
7 // Hierarchical data:
8 var tplData =
9 { title: "Jstemplates", items: [
10 { title: "Using Jstemplates", items: [
11 { title: "The Jstemplates Module"},
12 { title: "Javascript Data"},
13 { title: "Template HTML"},
14 { title: "Processing Templates with Javascript Statements"}
17 { title: "Template Processing Instructions", items: [
18 { title: "Processing Environment" },
19 { title: "Instruction Attributes", items: [
20 {title: "jscontent"}, {title: "jsselect"}, {title: "jsdisplay"},
21 {title: "transclude"},{title: "jsvalues"}, {title: "jsskip"}, {title: "jseval"}
24 ]};
26 var PEG_NAME = 'peg';
27 var TEMPLATE_NAME = 'tpl';
29 // Called by the body onload handler:
30 function jsinit() {
31 pegElement = domGetElementById(document, PEG_NAME);
32 loadData(pegElement, TEMPLATE_NAME, tplData);
35 function loadData(peg, templateId, data) {
36 // Get a copy of the template:
37 var templateToProcess = jstGetTemplate(templateId);
39 // Wrap our data in a context object:
40 var processingContext = new JsEvalContext(data);
42 // Process the template
43 jstProcess(processingContext, templateToProcess);
45 // Clear the element to which we'll attach the processed template:
46 peg.innerHTML = '';
48 // Attach the template:
49 domAppendChild(peg, templateToProcess);
51 </script>
52 <link rel="stylesheet" type="text/css" href="css/maps2.deb.css"/>
53 </head>
54 <body onload="jsinit()">
56 <!--
57 This is the div to which the instantiated template will be attached.
58 -->
59 <div id="peg"></div>
61 <!--
62 A container to hide our template:
63 -->
64 <div style="display:none">
65 <!--
66 This is the template div. It will be copied and attached to the div above with:
67 var apt = jstGetTemplate('apt');
68 appendChild(panel, apt)
69 -->
70 <div id="tpl">
71 <span jscontent="title">Outline heading</span>
72 <ul jsdisplay="items.length">
73 <li jsselect="items">
74 <!--Recursive tranclusion: -->
75 <div transclude="tpl"></div>
76 </li>
77 </ul>
78 </div>
80 </div>
81 </body>
82 </html>