diff options
author | Maxb <maxb.personal@gmail.com> | 2014-09-19 11:35:16 -0700 |
---|---|---|
committer | Maxb <maxb.personal@gmail.com> | 2014-09-19 11:35:16 -0700 |
commit | a0e2e200d91c719f6475f91f20fdaea2b7886340 (patch) | |
tree | dab8789f3dce1f672b5c528435268e0e34608f5c | |
parent | 3133af2a210a15223f441d75aa795f3e44bab3dd (diff) | |
download | handlebars.js-a0e2e200d91c719f6475f91f20fdaea2b7886340.zip handlebars.js-a0e2e200d91c719f6475f91f20fdaea2b7886340.tar.gz handlebars.js-a0e2e200d91c719f6475f91f20fdaea2b7886340.tar.bz2 |
Registering undefined partial throws exception.
-rw-r--r-- | lib/handlebars/base.js | 3 | ||||
-rw-r--r-- | spec/partials.js | 7 |
2 files changed, 10 insertions, 0 deletions
diff --git a/lib/handlebars/base.js b/lib/handlebars/base.js index 76f53e2..e0fda81 100644 --- a/lib/handlebars/base.js +++ b/lib/handlebars/base.js @@ -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; } }, diff --git a/spec/partials.js b/spec/partials.js index 20187f8..e239b7f 100644 --- a/spec/partials.js +++ b/spec/partials.js @@ -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}}"); |