JSFiddle - React, Tailwind, and code Playground

by mpetrovich

HTML

<script src="https://dl.dropbox.com/u/22528488/handlebars.js"></script>

JavaScript

var template, context, rendered;

// {{#each}} with an array
template = "<ul>{{#each data}}<li>{{@index}}: {{this}}</li>{{/each}}</ul>";
context = {
    data: ["one", "two", "three"]
};
rendered = Handlebars.compile(template)(context);
$("body").append(rendered);

// {{#each}} with an object
template = "<ul>{{#each data}}<li>{{@key}}: {{this}}</li>{{/each}}</ul>";
context = {
    data: {
        one: "un",
        two: "deux",
        three: "trois"
    }
};
rendered = Handlebars.compile(template)(context);
$("body").append(rendered);