JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://cdn.ractivejs.org/latest/ractive.js"></script>
<main></main>
<script id='template' type='text/ractive'>
<p>try typing a string in here. It should be coerced to a number or replaced with <code>undefined</code>, but it gets overridden on blur...</p>
<input value='{{foo}}'/>
<p>{{typeof foo}}: [{{foo}}]</p>
</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: { foo: '42' }
});
// emulate type='number' coercion
ractive.observe( 'foo', function ( foo ) {
var number = parseFloat(foo);
this.set( 'foo', isNaN(number) ? undefined : number );
});