Skip to content

Instantly share code, notes, and snippets.

@teaplanet
Last active August 29, 2015 14:12
Show Gist options
  • Save teaplanet/96daf16e5dcf6a7d5bb7 to your computer and use it in GitHub Desktop.
Save teaplanet/96daf16e5dcf6a7d5bb7 to your computer and use it in GitHub Desktop.
Ractive.js Tutorial 6-2
<!-- http://learn.ractivejs.org/list-sections/2 -->
<script src='http://cdn.ractivejs.org/latest/ractive.min.js'></script>
<div id='container'></div>
<script id='template' type='text/ractive'>
<table class='superheroes'>
<tr>
<th>#</th>
<th>Superhero name</th>
<th>Real name</th>
<th>Superpower</th>
</tr>
{{#each superheroes:num}}
<tr>
<td>{{num+1}}</td>
<td><a href='{{info}}'>{{name}}</a></td>
<td>{{realname}}</td>
<td>{{power}}</td>
</tr>
{{/each}}
</table>
</script>
// var ractive, xmen;
var xmen = [
{ name: 'Nightcrawler', realname: 'Wagner, Kurt', power: 'Teleportation', info: 'http://www.superherodb.com/Nightcrawler/10-107/' },
{ name: 'Cyclops', realname: 'Summers, Scott', power: 'Optic blast', info: 'http://www.superherodb.com/Cyclops/10-50/' },
{ name: 'Rogue', realname: 'Marie, Anna', power: 'Absorbing powers', info: 'http://www.superherodb.com/Rogue/10-831/' },
{ name: 'Wolverine', realname: 'Howlett, James', power: 'Regeneration', info: 'http://www.superherodb.com/Wolverine/10-161/' }
];
var ractive = new Ractive({
el: 'container',
template: '#template',
data: { superheroes: xmen }
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment