-
Notifications
You must be signed in to change notification settings - Fork 90
/
pure2.html
53 lines (50 loc) · 1.04 KB
/
pure2.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
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>pure3</title>
<script src="../libs/pure.js"></script>
</head>
<body>
<div style="display:none">
<div class="template">
<a href="http://"></a>
<span></span>
<input type="button" />
<ul>
<li class="animal">
<span class="name"></span>
<ol>
<li class="food"></li>
</ol>
</li>
</ul>
</div>
</div>
<div id="result"></div>
<script>
var data = {
who:'wrrrld',
id:'345',
href:'beebole.com',
site:'hello',
animals:[
{name:'cat', food:['mouse', 'meat']},
{name:'mouse', food:['cheese', 'grains']}
]
},
directive = {
'li.animal':{
'animal<-animals':{
'li.food':{
'food<-animal.food':{
}
}
}
}
}, rfn;
rfn = $p('div.template').compile(directive); //!the compiled function returns a DOM node, not a string anymore
document.getElementById('result').innerHTML = rfn(data);
</script>
</body>
</html>