2014-10-10 18:54:07 +04:00
|
|
|
// ### Page URL Helper
|
|
|
|
//
|
|
|
|
// *Usage example:*
|
|
|
|
// `{{page_url 2}}`
|
|
|
|
//
|
|
|
|
// Returns the URL for the page specified in the current object
|
|
|
|
// context.
|
|
|
|
//
|
|
|
|
// We use the name page_url to match the helper for consistency:
|
|
|
|
// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
|
2016-03-21 00:48:15 +03:00
|
|
|
var errors = require('../errors'),
|
2015-11-12 15:29:45 +03:00
|
|
|
i18n = require('../i18n'),
|
2016-03-21 00:48:15 +03:00
|
|
|
getPaginatedUrl = require('../data/meta/paginated_url'),
|
2014-10-10 18:54:07 +04:00
|
|
|
page_url,
|
|
|
|
pageUrl;
|
|
|
|
|
2016-03-21 00:48:15 +03:00
|
|
|
page_url = function (page, options) {
|
|
|
|
return getPaginatedUrl(page, options.data.root);
|
2014-10-10 18:54:07 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
// ### Page URL Helper: DEPRECATED
|
|
|
|
//
|
|
|
|
// *Usage example:*
|
|
|
|
// `{{pageUrl 2}}`
|
|
|
|
//
|
|
|
|
// Returns the URL for the page specified in the current object
|
|
|
|
// context. This helper is deprecated and will be removed in future versions.
|
|
|
|
//
|
2016-02-21 21:48:44 +03:00
|
|
|
pageUrl = function (pageNum, options) {
|
2015-11-12 15:29:45 +03:00
|
|
|
errors.logWarn(i18n.t('warnings.helpers.page_url.isDeprecated'));
|
2014-10-10 18:54:07 +04:00
|
|
|
|
|
|
|
/*jshint unused:false*/
|
|
|
|
var self = this;
|
|
|
|
|
2016-02-21 21:48:44 +03:00
|
|
|
return page_url.call(self, pageNum, options);
|
2014-10-10 18:54:07 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = page_url;
|
|
|
|
module.exports.deprecated = pageUrl;
|