-
Notifications
You must be signed in to change notification settings - Fork 0
/
ex6.html
65 lines (56 loc) · 1.61 KB
/
ex6.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<html>
<head>
<title>htmltmpl loop_context_vars option example</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<script type="text/javascript" src="htmltmpl/core.js"></script>
<script type="text/javascript">
var tmpl; // make tmpl a global var for debug purposes
function run()
{
var data;
data = { loop: [
{val1: "a", loop: [
{val1: "b", loop: [
{val1: "c"}]}]}]};
tmpl = new htmltmpl(document.getElementById("tmpl"),
{ ret_dom: 0 });
tmpl.tmpls.t = tmpl;
document.getElementById("cntr").innerHTML = tmpl.apply(data);
data = {val1: "a", loop: {
val1: "b", loop: {
val1: "c"}}};
tmpl = new htmltmpl(document.getElementById("tmpl1"),
{ ret_dom: 0 });
tmpl.tmpls.t = tmpl;
document.getElementById("cntr1").innerHTML = tmpl.apply(data);
}
</script>
</head>
<body onload="run()">
<div>
Example of using TMPL_INCLUDE.
</div>
<div id="tmpl" style="display: none">
{%TMPL_LOOP NAME=loop%}
<div style="border: 1px solid green; margin-bottom: 10px; margin-left: 40px;">
<div>
some var {%TMPL_VAR NAME=val1%}
</div>
{%TMPL_INCLUDE NAME=t%}
</div>
{%/TMPL_LOOP%}
</div>
<div id="tmpl1" style="display: none">
<div style="border: 1px solid green; margin-bottom: 10px; margin-left: 40px;">
<div>
some var {%TMPL_VAR NAME=val1%}
</div>
{%TMPL_INCLUDE NAME=t VAR=loop%}
</div>
</div>
<div id="cntr">
</div>
<div id="cntr1">
</div>
</body>
</html>