Skip to content

Instantly share code, notes, and snippets.

@pure
Created December 15, 2013 15:35
Show Gist options
  • Save pure/7974372 to your computer and use it in GitHub Desktop.
Save pure/7974372 to your computer and use it in GitHub Desktop.
<html>
<head>
<title>PURE Unobtrusive Rendering Engine</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="https://rawgithub.com/pure/pure/master/libs/pure.js"></script>
</head>
<body>
<table>
<thead>
<tr>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
</tr>
</tbody>
</table>
<script>
var cols = ['name', 'food', 'legs', 'button'],
data = [
{name:'bird', food:'seed', legs:2},
{name:'cat', food:'mouse, bird', legs:4},
{name:'dog', food:'bone', legs:4},
{name:'mouse', food:'cheese', legs:4}
],
colsDir = {
'th':{
'col<-':{
'.':'col'
}
},
'td':{
'col<-':{
'@class':'col'
}
}
},
dataDir = {
'tbody tr':{
'animal<-':{
'td.name':'animal.name',
'td.food':'animal.food',
'td.legs':'animal.legs',
'td.button':'<button onclick="alert(#{animal.legs})">View</button>'
}
}
};
$('table').render(cols, colsDir).render(data, dataDir);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment