JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://cdn.ractivejs.org/edge/ractive.js"></script>
<main></main>
<script id='template' type='text/ractive'>
{{#each listdata:i}}
<p>{{ .make }} {{ .model }}: ${{ format(.price) }} -> ${{ format( newprice( .price ) ) }}!</p>
{{/each}}
</script>
CSS
body {
font-family: 'Helvetica Neue', arial, sans-serif;
font-weight: 200;
color: #353535;
}
h1, h2, h3, h4, h5, h6 {
font-weight: 200;
}
JavaScript
var ractive = new Ractive({
el: 'main',
template: '#template',
data: {
listdata: [
{ make: 'Toyota', model: 'Prius', price: 35000 },
{ make: 'Dodge', model: 'Challenger', price: 30000 },
{ make: 'Jeep', model: 'Grand Cherokee', price: 35000 },
{ make: 'Bugatti', model: 'Veyron', price: 2000000 }
],
discount: 0.1,
newprice: function ( oldprice ) {
return oldprice * ( 1 - this.get( 'discount' ) );
},
format: function ( number ) {
// add comma separators
return number.toString().replace( /\B(?=(\d{3})+(?!\d))/g, ',' );
}
}
});