Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass full helper ID to helperMissing when options are provided #797

Merged
merged 1 commit into from
May 20, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/handlebars/compiler/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ Compiler.prototype = {
throw new Exception("You specified knownHelpersOnly, but used the unknown helper " + name, sexpr);
} else {
this.ID(id);
this.opcode('invokeHelper', params.length, name, sexpr.isRoot);
this.opcode('invokeHelper', params.length, id.original, sexpr.isRoot);
}
},

Expand Down
8 changes: 8 additions & 0 deletions spec/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ describe('helpers', function() {
shouldCompileTo(string, [hash, helpers], "Message: Goodbye cruel world", "block helpers with multiple params");
});
});

describe('hash', function() {
it("helpers can take an optional hash", function() {
var template = CompilerContext.compile('{{goodbye cruel="CRUEL" world="WORLD" times=12}}');
Expand Down Expand Up @@ -473,6 +474,9 @@ describe('helpers', function() {
blockHelperMissing: function() {
return 'missing: ' + arguments[arguments.length-1].name;
},
helperMissing: function() {
return 'helper missing: ' + arguments[arguments.length-1].name;
},
helper: function() {
return 'ran: ' + arguments[arguments.length-1].name;
}
Expand Down Expand Up @@ -502,6 +506,10 @@ describe('helpers', function() {
it('should include full id', function() {
shouldCompileTo('{{#foo.helper}}{{/foo.helper}}', [{foo: {}}, helpers], 'missing: foo.helper');
});

it('should include full id if a hash is passed', function() {
shouldCompileTo('{{#foo.helper bar=baz}}{{/foo.helper}}', [{foo: {}}, helpers], 'helper missing: foo.helper');
});
});

describe('name conflicts', function() {
Expand Down