From 7a52ddeba2a68388b544f529d2d92104420f77b0 Mon Sep 17 00:00:00 2001 From: Shipwreckt Date: Fri, 31 Oct 2025 20:02:14 +0000 Subject: Changed from static to 11ty! --- node_modules/nunjucks/src/globals.js | 65 ++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 node_modules/nunjucks/src/globals.js (limited to 'node_modules/nunjucks/src/globals.js') diff --git a/node_modules/nunjucks/src/globals.js b/node_modules/nunjucks/src/globals.js new file mode 100644 index 0000000..e0de671 --- /dev/null +++ b/node_modules/nunjucks/src/globals.js @@ -0,0 +1,65 @@ +'use strict'; + +function _cycler(items) { + var index = -1; + return { + current: null, + reset: function reset() { + index = -1; + this.current = null; + }, + next: function next() { + index++; + if (index >= items.length) { + index = 0; + } + this.current = items[index]; + return this.current; + } + }; +} +function _joiner(sep) { + sep = sep || ','; + var first = true; + return function () { + var val = first ? '' : sep; + first = false; + return val; + }; +} + +// Making this a function instead so it returns a new object +// each time it's called. That way, if something like an environment +// uses it, they will each have their own copy. +function globals() { + return { + range: function range(start, stop, step) { + if (typeof stop === 'undefined') { + stop = start; + start = 0; + step = 1; + } else if (!step) { + step = 1; + } + var arr = []; + if (step > 0) { + for (var i = start; i < stop; i += step) { + arr.push(i); + } + } else { + for (var _i = start; _i > stop; _i += step) { + // eslint-disable-line for-direction + arr.push(_i); + } + } + return arr; + }, + cycler: function cycler() { + return _cycler(Array.prototype.slice.call(arguments)); + }, + joiner: function joiner(sep) { + return _joiner(sep); + } + }; +} +module.exports = globals; \ No newline at end of file -- cgit v1.2.3