Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 55 lines (54 sloc) 1.006 kB
bc00883 @pure allow @ in the name of a JSON property, add tutorial 5c
authored
1 <html>
2 <head>
3 <title>PURE Unobtrusive Rendering Engine</title>
4 <script src="../libs/jquery.js"></script>
5 <script src="../libs/pure.js"></script>
6 </head>
7 <body>
8 <table>
9 <thead>
10 <tr>
11 <th></th>
12 </tr>
13 </thead>
14 <tbody>
15 <tr>
16 <td></td>
17 </tr>
18 </tbody>
19 </table>
20
21 <script>
22 var cols = ['name', 'food', 'legs', 'button'],
23 data = {animals:[
24 {name:'bird', food:'seed', legs:2},
25 {name:'cat', food:'mouse, bird', legs:4},
26 {name:'dog', food:'bone', legs:4},
27 {name:'mouse', food:'cheese', legs:4}
28 ]
29 },
30 colsDir = {
31 'th':{
32 'col<-':{
33 '.':'col'
34 }
35 },
36 'td':{
37 'col<-':{
38 '@class':'col'
39 }
40 }
41 },
42 dataDir = {
43 'tbody tr':{
44 'animal<-animals':{
45 'td.name':'animal.name',
46 'td.food':'animal.food',
47 'td.legs':'animal.legs',
48 'td.button':'<button onclick="alert(#{animal.legs})">View</button>'
49 }
50 }
51 };
52 $('table').render(cols, colsDir).render(data, dataDir);
53 </script>
54 </body>
55 </html>
Something went wrong with that request. Please try again.