Skip to content

Commit

Permalink
Restore knownHelpersOnly throw
Browse files Browse the repository at this point in the history
Fixes #302
  • Loading branch information
kpdecker committed Apr 7, 2013
1 parent 12d68ca commit f6ff5c6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/handlebars/compiler/compiler.js
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions spec/qunit_spec.js
Expand Up @@ -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");

Expand Down

0 comments on commit f6ff5c6

Please sign in to comment.