-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathstatements.html
83 lines (70 loc) · 1.4 KB
/
statements.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
82
83
<!DOCTYPe html>
<html>
<head>
<script type='text/mask' id='layout'>
// IF
if (one) {
.if-one > '
(if) <if> Should be rendered
'
}
if (!one) {
.none > '(if-else) <if> If should not be rendered'
} else {
.if-one-else > '
(if-else) <else> Should be rendered
'
}
// SWITCH
switch (one + 1) {
case (1) {
.switch-not-expect;
}
case (2) {
.switch-expect;
}
default {
.switch-not-expect;
}
}
// FOR..OF
for (user of users) {
.for-of > '(for..of) Should be rendered twice ~[user.name]'
}
for ((user, index) of users) {
.for-of > '(for..of) Should be rendered twice ~[user.name]'
}
// FOR..IN
for (key in settings) {
.for-in > '(for..in) Should be rendered twice ~[key]'
}
for ((key, value) in settings) {
.for-in > '(for..in) Should be rendered twice ~[key]: ~[value]'
}
// EACH
each(users) {
.each > '(each) Should be rendered twice ~[name]'
}
</script>
<script src='../lib/mask.js'></script>
<script>
window.onload = function(){
var template = document.querySelector('#layout').textContent,
model = {
one: 1,
users: [
{ name: 'foo' },
{ name: 'baz' }
],
settings: {
theme: 'default',
amount: 2
}
}
fragment = mask.render(template, model);
document.body.appendChild(fragment);
};
</script>
</head>
<body></body>
</html>