Skip to content

Instantly share code, notes, and snippets.

@pure
Created April 10, 2011 19:56
Show Gist options
  • Save pure/912665 to your computer and use it in GitHub Desktop.
Save pure/912665 to your computer and use it in GitHub Desktop.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title></title>
<script src="http://github.com/pure/pure/raw/master/libs/pure.js"></script>
</head>
<body>
<body>
<table border="1">
<tbody>
<tr class="head">
<td colspan="4"></td>
</tr>
<tr class="row">
<td></td>
</tr>
</tbody>
</table>
<script>
var data = {
heads:[
{
title:'HEAD A',
rows:[
{col1:'a', col2:'b', col3:'c', col4:'d'},
{col1:'aaa', col2:'bb', col3:'cc', col4:'dddd'}
]
}, {
title:'HEAD B',
rows:[
{col1:'aa', col2:'b', col3:'cccc', col4:'ddddd'}
]
}
]
};
$p('table').render(data, {
'tbody':{ //repeat tbody for each heads
'head<-heads':{
'tr.head td':'head.title',
'tr.row':{ //repeat tr.row for each rows
'row<-head.rows':{
'td':{ //repeat td for each element found in row
'col<-row':{
'.':'col' //set the td to the col value
}
}
}
}
}
}
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment