mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-02 07:43:11 +03:00
🎨 Improved pagination misusage error
refs https://github.com/TryGhost/Team/issues/41, refs https://github.com/TryGhost/gscan/issues/85 - if you are using the pagination helper not inside a resource context, you will receive an error - improve error message, because it was not clear what happened - downgrade error level to normal, because it's not a critical error from Ghost's perspective, from user perspective it is - added help docs link and added a callout to our docs
This commit is contained in:
parent
2f23cd32bb
commit
e8075262eb
@ -12,7 +12,9 @@ var proxy = require('./proxy'),
|
||||
pagination = function (options) {
|
||||
if (!_.isObject(this.pagination) || _.isFunction(this.pagination)) {
|
||||
throw new errors.IncorrectUsageError({
|
||||
message: i18n.t('warnings.helpers.pagination.invalidData')
|
||||
level: 'normal',
|
||||
message: i18n.t('warnings.helpers.pagination.invalidData'),
|
||||
help: 'https://themes.ghost.org/docs/pagination'
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -524,7 +524,7 @@
|
||||
"isDeprecated": "Warning: pageUrl is deprecated, please use page_url instead\nThe helper pageUrl has been replaced with page_url in Ghost 0.4.2, and will be removed entirely in Ghost 0.6\nIn your theme's pagination.hbs file, pageUrl should be renamed to page_url"
|
||||
},
|
||||
"pagination": {
|
||||
"invalidData": "pagination data is not an object or is a function",
|
||||
"invalidData": "The \\{\\{pagination\\}\\} helper was used outside of a paginated context. See https://themes.ghost.org/docs/pagination.",
|
||||
"valuesMustBeDefined": "All values must be defined for page, pages, limit and total",
|
||||
"nextPrevValuesMustBeNumeric": "Invalid value, Next/Prev must be a number",
|
||||
"valuesMustBeNumeric": "Invalid value, check page, pages, limit and total are numbers"
|
||||
|
@ -29,11 +29,11 @@ describe('{{pagination}} helper', function () {
|
||||
return function () {
|
||||
helpers.pagination.call(data);
|
||||
};
|
||||
};
|
||||
}, expectedMessage = 'The {{pagination}} helper was used outside of a paginated context. See https://themes.ghost.org/docs/pagination.';
|
||||
|
||||
runHelper('not an object').should.throwError('pagination data is not an object or is a function');
|
||||
runHelper('not an object').should.throwError(expectedMessage);
|
||||
runHelper(function () {
|
||||
}).should.throwError('pagination data is not an object or is a function');
|
||||
}).should.throwError(expectedMessage);
|
||||
});
|
||||
|
||||
it('can render single page with no pagination necessary', function () {
|
||||
|
Loading…
Reference in New Issue
Block a user