diff --git a/lib/handlebars/compiler/compiler.js b/lib/handlebars/compiler/compiler.js index b31d92b2d..dc17020ca 100644 --- a/lib/handlebars/compiler/compiler.js +++ b/lib/handlebars/compiler/compiler.js @@ -272,7 +272,7 @@ Compiler.prototype = { if (this.options.knownHelpers[name]) { this.opcode('invokeKnownHelper', params.length, name); - } else if (this.knownHelpersOnly) { + } else if (this.options.knownHelpersOnly) { throw new Error("You specified knownHelpersOnly, but used the unknown helper " + name); } else { this.opcode('invokeHelper', params.length, name); diff --git a/spec/qunit_spec.js b/spec/qunit_spec.js index 6c44e4e0d..fefb8ecd9 100644 --- a/spec/qunit_spec.js +++ b/spec/qunit_spec.js @@ -709,6 +709,11 @@ test("Functions are bound to the context in knownHelpers only mode", function() var result = template({foo: function() { return this.bar; }, bar: 'bar'}); equal(result, "bar", "'bar' should === '" + result); }); +test("Unknown helper call in knownHelpers only mode should throw", function() { + shouldThrow(function() { + CompilerContext.compile("{{typeof hello}}", {knownHelpersOnly: true}); + }, Error, 'specified knownHelpersOnly'); +}); suite("blockHelperMissing");