Skip to content

Commit

Permalink
Added a range swig function
Browse files Browse the repository at this point in the history
I found it useful when generating pagination for example
{{ range(maxNumPages) }}
  • Loading branch information
alex-e-leon committed Jan 11, 2016
1 parent f35b9b6 commit 945fa25
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion libs/swig_functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,10 @@ module.exports.swigFunctions = function(swig) {
return self.maxPage;
};

var range = function(args) {
return _.range(args);
};

var getPageUrl = function(pageNum) {
if(pageNum == 1) {
return self.paginationBaseUrl;
Expand Down Expand Up @@ -628,6 +632,7 @@ module.exports.swigFunctions = function(swig) {
getCurPage: getCurPage,
getMaxPage: getMaxPage,
getPageUrl: getPageUrl,
range: range,
url: url,
getCurrentUrl: getCurrentUrl,
getSetting: getSetting,
Expand Down Expand Up @@ -668,4 +673,4 @@ module.exports.swigFunctions = function(swig) {


return this;
};
};

0 comments on commit 945fa25

Please sign in to comment.