-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathinterpolation.html
79 lines (64 loc) · 1.44 KB
/
interpolation.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
<!DOCTYPe html>
<html>
<head>
<script type='text/mask' id='layout'>
h4.model {
// model accessor
div > 'Section: ~[sectionTitle]'
// expression
small > em > '~[: sectionTitle.toLowerCase() ]'
}
// extract user's model sample
with(user) {
:user .user-compo {
// components scope sample
h6 > '~[userTitle]'
// interpolation util
.user-date > '~[format:date]'
}
}
select #themes {
each(themes) {
option name='~[.]' > '~[.]'
}
}
// expression
h6.settings >
'Settings ~[: settings.amount * 100 / 2 ]'
</script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script src='../lib/mask.js'></script>
<script>
mask.registerHandler(':user', mask.Compo({
tagName: 'div',
scope: {
userTitle: '"User" Component'
}
}));
mask.registerUtil('format', function(key, model){
var date = model[key];
return date.getFullYear() + '-' + date.getMonth();
});
window.onload = function(){
var template = document.querySelector('#layout').textContent,
model = {
sectionTitle: 'Interpolations',
user: {
date: new Date(2014, 0, 1)
},
settings: {
theme: 'default',
amount: 2
},
themes: [
'default',
'dark'
]
}
fragment = mask.render(template, model);
document.body.appendChild(fragment);
};
</script>
</head>
<body></body>
</html>