-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.html
81 lines (69 loc) · 2.66 KB
/
test.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<!DOCTYPE html>
<html>
<head>
<title>Template Test</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="text/html" id="template">
<{tmpl}>
hallo
<{js:
// plain js code here
var a = 2,
b = 3,
c = 7, neVar = "foo bar";
for(var i = 0; i < 20; i++)
print((i*a*b*c) + "<br />");
//console.log("console.log");
}/>
<div>
< { if : 1 == 2}>
ergibt false
<{else}>
neVar -> <{neVar}>
</{if}>
<{for: i = 0; i < 20; i++}>
count: <{i}> <br />
</{for}>
<{js: var arr = [2,4,6,8,"..."];}/>
<{for: i in arr}>
elem: <{arr[i]}> <br />
</{for}>
<{js: var objOrArr = [2,3,5,7, 11, 13, 17, 18, 21,"..."];}/>
<{for: objOrArr => key, val}>
zeile: <{inc: zeile}>
</{for}>
</div>
</{tmpl}>
wird ignoriert weil auserhalb von "tmpl"
kann auch für kommentare benutzt werden ..
<{tmpl: zeile}>
<{js: var
bla = "ein bla string",
rnd = Math.random();
}>
<{key}>(<{rnd}>): <{val}> <br />
<{inc: noch ein template}/> <br />
</{tmpl}>
<{tmpl: noch ein template}>
dies ist <span>noch ein template</span>
</{tmpl}>
</script>
<script src="./js/template.js" type="text/javascript"></script>
<script type="text/javascript">
!function()
{
var tmpl = new Template(document.getElementById("template").innerHTML),
parsed = tmpl.render(); //{neVar: "hallo welt"});
console.log(tmpl, parsed);
window.addEventListener("load", function()
{
document.body.innerHTML = parsed;
});
}();
</script>
</head>
<body>
<div>javascript muss aktiviert sein</div>
</body>
</html>