Permalink
Browse files

Restore knownHelpersOnly throw

Fixes #302
  • Loading branch information...
1 parent 12d68ca commit f6ff5c648b6e576d8b6f48ea2a6291dcc6a9e5be @kpdecker kpdecker committed Apr 7, 2013
Showing with 6 additions and 1 deletion.
  1. +1 −1 lib/handlebars/compiler/compiler.js
  2. +5 −0 spec/qunit_spec.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);
View
@@ -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");

0 comments on commit f6ff5c6

Please sign in to comment.