-
Notifications
You must be signed in to change notification settings - Fork 0
/
ex5.html
59 lines (53 loc) · 1.53 KB
/
ex5.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
<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" src="htmltmpl/ifeq.js"></script>
<script type="text/javascript">
var tmpl; // make tmpl a global var for debug purposes
function run()
{
var el;
var data;
data = { val1: "a", val2: "b", val3: 5};
tmpl = new htmltmpl(document.getElementById("tmpl"),
{ ret_dom: 1 });
el = tmpl.apply(data);
document.getElementById("cntr").appendChild(el);
}
</script>
</head>
<body onload="run()">
<div>
Example of using IFEQ, IFNEQ, IFGT, IFGE, IFLT, IFLE.
</div>
<div id="tmpl" style="display: none"><div style="border: 1px solid green; margin-bottom: 10px">
{%TMPL_IFEQ NAME=val1 VALUE="a"%}
<div>val1 == "a"</div>
{%/TMPL_IFEQ%}
{%TMPL_IFNEQ NAME=val2 WITH=val1%}
<div>val2 != val1</div>
{%/TMPL_IFNEQ%}
{%TMPL_IFEQ NAME=val1 WITH=val2%}
<div>val1 == val2</div>
{%TMPL_ELSE%}
<div>val1 != val2</div>
{%/TMPL_IFEQ%}
{%TMPL_IFGT NAME=val3 VALUE=4%}
<div>val3 > 4</div>
{%/TMPL_IFGT%}
{%TMPL_IFGE NAME=val3 VALUE=5%}
<div>val3 >= 5</div>
{%/TMPL_IFGE%}
{%TMPL_IFLT NAME=val3 VALUE=6%}
<div>val3 < 6</div>
{%/TMPL_IFLT%}
{%TMPL_IFLE NAME=val3 VALUE=5%}
<div>val3 <= 5</div>
{%/TMPL_IFLE%}
</div></div>
<div id="cntr">
</div>
</body>
</html>