Merge pull request #797 from tomdale/full-helper-names

Pass full helper ID to helperMissing when options are provided
This commit is contained in:
Kevin Decker
2014-05-19 21:59:20 -05:00
2 changed files with 9 additions and 1 deletions
+1 -1
View File
@@ -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);
}
},
+8
View File
@@ -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}}');
@@ -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;
}
@@ -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() {