JSFiddle - React, Tailwind, and code Playground
HTML
<script type="text/javascript"
src="http://builds.handlebarsjs.com.s3.amazonaws.com/handlebars-c90cfe2.js"></script>
<div id="output"></div>
JavaScript
Handlebars.registerHelper('helper1', function (foo, text) {
return 'FOO: ' + foo + ', FOO.TEXT: ' + text;
});
var tmpl = Handlebars.compile('{{helper1 foo foo.text}} ({{foo}}, {{foo.text}})<br/>');
document.getElementById('output').innerHTML += tmpl();
document.getElementById('output').innerHTML += tmpl({ foo: ['a']});
document.getElementById('output').innerHTML += tmpl({ foo: []});
document.getElementById('output').innerHTML += tmpl({ foo: {} });
document.getElementById('output').innerHTML += tmpl({ foo: 1 });
document.getElementById('output').innerHTML += tmpl({ foo: 2 });
// foo.text should be undefined? but we got false
document.getElementById('output').innerHTML += tmpl({ foo: false });
// foo.text should be undefined? but we got null
document.getElementById('output').innerHTML += tmpl({ foo: null });
// foo.text should be undefined? but we got 0
document.getElementById('output').innerHTML += tmpl({ foo: 0 });