Fix falsy helpers (like 0)

This commit is contained in:
David Greenspan
2014-09-24 16:39:33 -07:00
parent dee69bde0b
commit fe5c61104f
3 changed files with 14 additions and 1 deletions

View File

@@ -64,7 +64,7 @@ Blaze.View.prototype.lookup = function (name, _options) {
} else if (lookupTemplate && (name in Blaze.Template) &&
(Blaze.Template[name] instanceof Blaze.Template)) {
return Blaze.Template[name];
} else if (Blaze._globalHelpers[name]) {
} else if (Blaze._globalHelpers[name] != null) {
return wrapHelper(bindDataContext(Blaze._globalHelpers[name]));
} else {
return function () {

View File

@@ -992,3 +992,7 @@ Hi there!
{{/with}}
{{/with}}
</template>
<template name="spacebars_template_test_falsy_helper">
foo:{{foo}} GLOBAL_ZERO:{{GLOBAL_ZERO}}
</template>

View File

@@ -2903,3 +2903,12 @@ Tinytest.add("spacebars-tests - template_tests - content context back-compat", f
Tracker.flush();
test.equal(canonicalizeHtml(div.innerHTML), 'FA');
});
Tinytest.add("spacebars-tests - template_tests - falsy helper", function (test) {
var tmpl = Template.spacebars_template_test_falsy_helper;
tmpl.foo = 0;
Template.registerHelper('GLOBAL_ZERO', 0);
var div = renderToDiv(tmpl);
test.equal(canonicalizeHtml(div.innerHTML), 'foo:0 GLOBAL_ZERO:0');
});