Improve error-message when partial is missing
Signed-off-by: Seyed Mohammad Mahdi Hatami <hatamik7@gmail.com>
This commit is contained in:
committed by
Jay Linski
parent
d3b93571a7
commit
8ce2be4496
@@ -376,7 +376,9 @@ export function invokePartial(partial, context, options) {
|
||||
}
|
||||
|
||||
if (partial === undefined) {
|
||||
throw new Exception('The partial ' + options.name + ' could not be found');
|
||||
throw new Exception(
|
||||
'The partial "' + options.name + '" could not be found'
|
||||
);
|
||||
} else if (partial instanceof Function) {
|
||||
return partial(context, options);
|
||||
}
|
||||
|
||||
+7
-4
@@ -64,7 +64,10 @@ describe('partials', function () {
|
||||
return 'missing';
|
||||
})
|
||||
.withPartial('dude', '{{name}} ({{url}}) ')
|
||||
.toThrow(Handlebars.Exception, 'The partial missing could not be found');
|
||||
.toThrow(
|
||||
Handlebars.Exception,
|
||||
'The partial "missing" could not be found'
|
||||
);
|
||||
});
|
||||
|
||||
it('partials with context', function () {
|
||||
@@ -156,7 +159,7 @@ describe('partials', function () {
|
||||
it('rendering undefined partial throws an exception', function () {
|
||||
expectTemplate('{{> whatever}}').toThrow(
|
||||
Handlebars.Exception,
|
||||
'The partial whatever could not be found'
|
||||
'The partial "whatever" could not be found'
|
||||
);
|
||||
});
|
||||
|
||||
@@ -174,7 +177,7 @@ describe('partials', function () {
|
||||
it('rendering template partial in vm mode throws an exception', function () {
|
||||
expectTemplate('{{> whatever}}').toThrow(
|
||||
Handlebars.Exception,
|
||||
'The partial whatever could not be found'
|
||||
'The partial "whatever" could not be found'
|
||||
);
|
||||
});
|
||||
|
||||
@@ -472,7 +475,7 @@ describe('partials', function () {
|
||||
|
||||
expectTemplate(
|
||||
'{{#with .}}{{#*inline "myPartial"}}success{{/inline}}{{/with}}{{> myPartial}}'
|
||||
).toThrow(Error, /myPartial could not/);
|
||||
).toThrow(Error, /"myPartial" could not/);
|
||||
});
|
||||
|
||||
it('should override global partials', function () {
|
||||
|
||||
Reference in New Issue
Block a user