JSFiddle - React, Tailwind, and code Playground

by rich_harris

HTML

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

<script id='template' type='text/ractive'>
    <button on-click='set("type","foo")'>set type to foo</button>
    <button on-click='set("type","bar")'>set type to bar</button>
    <button on-click='set("type","baz")'>set type to baz</button>
    
    <div class='thing'>
        {{>type}}
    </div>
</script>

CSS

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;
}

JavaScript

var ractive = new Ractive({
    el: 'main',
    template: '#template',
    data: {
        type: 'foo',
        content: 'this is some dynamic content'
    },
    partials: {
        foo: '<p>I am a type foo: {{content}}</p>',
        bar: '<p><em>I, meanwhile, am of type bar: {{content}}. I say again, {{content}}</em></p>',
        baz: '<a href="http://bit.ly/QOyWC1"><img src="http://learn.ractivejs.org/gifs/image.gif"/></a>'
    }
});