Registering undefined partial throws exception.

This commit is contained in:
Maxb
2014-09-19 11:35:16 -07:00
parent 3133af2a21
commit a0e2e200d9
2 changed files with 10 additions and 0 deletions
+3
View File
@@ -47,6 +47,9 @@ HandlebarsEnvironment.prototype = {
if (toString.call(name) === objectType) {
Utils.extend(this.partials, name);
} else {
if (typeof partial === 'undefined') {
throw new Exception('Attempting to register a partial as undefined');
}
this.partials[name] = partial;
}
},
+7
View File
@@ -46,6 +46,13 @@ describe('partials', function() {
}, Handlebars.Exception, 'The partial whatever could not be found');
});
it("registering undefined partial throws an exception", function() {
shouldThrow(function() {
var undef;
handlebarsEnv.registerPartial('undefined_test', undef);
}, Handlebars.Exception, 'Attempting to register a partial as undefined');
});
it("rendering template partial in vm mode throws an exception", function() {
shouldThrow(function() {
var template = CompilerContext.compile("{{> whatever}}");