Skip to content

Instantly share code, notes, and snippets.

@ghstahl
Last active October 20, 2016 17:51
Show Gist options
  • Save ghstahl/56fa840399c947a3c8d17ce70022aeea to your computer and use it in GitHub Desktop.
Save ghstahl/56fa840399c947a3c8d17ce70022aeea to your computer and use it in GitHub Desktop.
RiotJs simple-table Tag
<simple-table>
<table class="highlight">
<thead>
<tr>
<h5>{title}</h5>
<th each={ name, i in cols }>{name}</th>
</tr>
</thead>
<tbody>
<tr each={row in rows } >
<td each={ name in row }>{name}</td>
</tr>
</tbody>
</table>
<script>
var self = this;
// an array of strings ["column1","column2"]
self.cols = [];
// an string "My Title"
self.title = null;
/*
An array or string arrays.
self.scopes = ["offline_acess","api1"]
self.scopesT = self.scopes.map(function(item) {
return ['scope',item];
});
[
['a','b'],
['c','d'],
]
*/
self.rows = [[]];
self.on('mount', function() {
self.cols = opts.cols;
self.title = opts.title;
self.rows = opts.rows;
console.log('mount:simple-table',self.title,'cols:',self.cols ,'rows:',self.rows )
})
self.on('update', function() {
self.cols = opts.cols;
self.title = opts.title;
self.rows = opts.rows;
console.log('update:simple-table',self.title,'cols:',self.cols ,'rows:',self.rows )
})
</script>
</simple-table>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment