JSFiddle - React, Tailwind, and code Playground
by bertrandg
HTML
<script src="//cdnjs.cloudflare.com/ajax/libs/handlebars.js/2.0.0-alpha.2/handlebars.js"></script>
<div id="output"></div>
<script type="template/handlebars" id="template">
{{#if .}}
Items:
{{#each .}}
[ item {{.}} ]
{{/each}}
{{^}}
No item
{{/if}}
<p>--</p>
{{#if .}} {{! <==== the dot must be left here }}
Items:
{{#each }} {{! <==== when it can be removed here }}
[ item {{.}} ]
{{/each}}
{{^}}
No item
{{/if}}
</script>
JavaScript
var template = Handlebars.compile(document.getElementById('template').innerHTML);
document.getElementById('output').innerHTML = template([1,2]);