JSFiddle - React, Tailwind, and code Playground

by rich_harris

HTML

<script src="http://cdn.ractivejs.org/edge/ractive.js"></script>
<main></main>
<pre id='html'></pre>

<script id='template' type='text/ractive'>
<p {{#if foo}}data-foo{{/if}}>right-click, inspect this element. then toggle foo</p>
<label><input type='checkbox' checked='{{foo}}'/>foo</label>
<p>(it will show up as <code>data-foo=""</code> below, but as <code>data-foo</code> in the inspector)</p>
</script>

CSS

[data-foo] {
    color: red;
}

body {
    font-family: 'Helvetica Neue', arial, sans-serif;
    font-weight: 200;
    color: #353535;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 200;
}

.error {
    color: #d00;
    font-family: monospace;
}

label {
    display: block;
}

JavaScript

var ractive = new Ractive({
    el: 'main',
    template: '#template',
    data: {
        foo: false
    },
    preserveWhitespace: true
});

ractive.observe( 'foo', function () {
    html.innerText = ractive.el.innerHTML;
}, { defer: true });