Skip to content
This repository was archived by the owner on Sep 25, 2021. It is now read-only.

Commit 11b8a4c

Browse files
committed
This is a demo of using javascript-tmpl
1 parent 587fd7c commit 11b8a4c

File tree

1 file changed

+99
-0
lines changed

1 file changed

+99
-0
lines changed

test/demoByminyin.html

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
<h1>Status_Title</h1>
2+
<h3>Status_Description</h3>
3+
<table>
4+
<tr>
5+
<td colspan="8">Status_Table_Title</td>
6+
</tr>
7+
<tr>
8+
<td>Device_Id</td>
9+
<td>Chip_Info</td>
10+
<td>Status</td>
11+
<td>Frequency</td>
12+
<td>Methods</td>
13+
<td>Speed</td>
14+
<td>Type</td>
15+
<td>Power</td>
16+
</tr>
17+
</table>
18+
<div id="tmpl_traffic">This is a div</div>
19+
20+
<script src="../js/tmpl.min.js"></script>
21+
<script type="text/x-tmpl" id="tmpl-demo">
22+
<h3>{%=o.title%}</h3>
23+
<p>Released under the
24+
<a href="{%=o.license.url%}">{%=o.license.name%}</a>.</p>
25+
<h4>Features</h4>
26+
<ul>
27+
{% for (var i=0; i<o.features.length; i++) { %}
28+
<li>{%=o.features[i]%}</li>
29+
{% } %}
30+
</ul>
31+
</script>
32+
33+
<script>
34+
var data = {
35+
"title": "JavaScript Templates",
36+
"license": {
37+
"name": "MIT license",
38+
"url": "http://www.opensource.org/licenses/MIT"
39+
},
40+
"features": [
41+
"lightweight & fast",
42+
"powerful",
43+
"zero dependencies"
44+
]
45+
};
46+
//$dot = $("#tmpl_traffic");
47+
//$dot.nextAll().remove();
48+
document.getElementById("tmpl_traffic").innerHTML = tmpl("tmpl-demo", data);
49+
//$("#tmpl_traffic").innerHTML = tmpl("tmpl-demo", data);
50+
//$(tmpl('tmpl-demo', data)).insertAfter($dot)
51+
</script>
52+
53+
<!--script type="text/x-tmpl" id="tmpl_traffic">
54+
{% $.each(o, function(id, it){ %}
55+
<tr>
56+
<td>{%=id %}</td>
57+
<td>{%=it.ChipInfo %}</td>
58+
<td>{%=it.LockStatus %}</td>
59+
<td>{%=it.Freq %}</td>
60+
<td>{%=it.Methods %}</td>
61+
<td>{%=it.Speed %}</td>
62+
<td>{%=it.Type %}</td>
63+
<td>{%=it.Power %}</td>
64+
</tr>
65+
{% }}) %}
66+
</script-->
67+
68+
<!--script>
69+
var data = {
70+
"title": "JavaScript Templates",
71+
"license": {
72+
"name": "MIT license",
73+
"url": "http://www.opensource.org/licenses/MIT"
74+
},
75+
"data":{
76+
"1":{
77+
"ChipInfo": "Qualcomm",
78+
"LockStatus": "Lock",
79+
"Freq": "1150",
80+
"Methods": "Hide",
81+
"Speed": "High",
82+
"Type": "na",
83+
"Power": "300w"
84+
},
85+
"2":{
86+
"ChipInfo": "Intel",
87+
"LockStatus": "Not Lock",
88+
"Freq": "1250",
89+
"Methods": "Hide",
90+
"Speed": "High",
91+
"Type": "ie",
92+
"Power": "500w"
93+
}
94+
}
95+
};
96+
$dot = $('[data-tmpl-replace="tmpl_traffic"]');
97+
$dot.nextAll().remove();
98+
$(tmpl('tmpl_traffic', data.data)).insertAfter($dot)
99+
</script-->

0 commit comments

Comments
 (0)