summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/handlebars/compiler/javascript-compiler.js7
-rw-r--r--spec/regressions.js8
2 files changed, 11 insertions, 4 deletions
diff --git a/lib/handlebars/compiler/javascript-compiler.js b/lib/handlebars/compiler/javascript-compiler.js
index d9c23ee..a6930f0 100644
--- a/lib/handlebars/compiler/javascript-compiler.js
+++ b/lib/handlebars/compiler/javascript-compiler.js
@@ -377,10 +377,9 @@ JavaScriptCompiler.prototype = {
for (; i < len; i++) {
this.replaceStack(function(current) {
var lookup = this.nameLookup(current, parts[i], 'context');
- // We want to ensure that zero and false are handled properly for the first element
- // of non-chained elements, if the context (falsy flag) needs to have the special
- // handling for these values.
- if (!falsy && !i && len === 1) {
+ // We want to ensure that zero and false are handled properly if the context (falsy flag)
+ // needs to have the special handling for these values.
+ if (!falsy) {
return ' != null ? ' + lookup + ' : ' + current;
} else {
// Otherwise we can use generic falsy handling
diff --git a/spec/regressions.js b/spec/regressions.js
index d4598cc..11207fc 100644
--- a/spec/regressions.js
+++ b/spec/regressions.js
@@ -137,4 +137,12 @@ describe('Regressions', function() {
it('GH-820: zero pathed rendering', function() {
shouldCompileTo('{{foo.bar}}', {foo: 0}, '');
});
+
+ it('GH-837: undefined values for helpers', function() {
+ var helpers = {
+ str: function(value) { return value + ''; }
+ };
+
+ shouldCompileTo('{{str bar.baz}}', [{}, helpers], 'undefined');
+ });
});