diff --git a/CHANGELOG.md b/CHANGELOG.md index ce394fd4..99e89c16 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,13 +2,28 @@ Changelog ========= -master (unreleased) ----------------- +3.0.1 (May 24 2017) +------------------- * Fix handling methods and attributes of static arrays, objects and primitives. Solves the issue [#937](https://github.com/mozilla/nunjucks/issues/937) -* Add support for python-style array slices with Jinja compat enabled. Thanks - Frankie Dintino. + +* Add support for python-style array slices with Jinja compat enabled. + Fixes [#188](https://github.com/mozilla/nunjucks/issues/188); merge of + [#976](https://github.com/mozilla/nunjucks/pull/976). + +* Fix call blocks having access to their parent scope. Fixes + [#906](https://github.com/mozilla/nunjucks/issues/906); merge of + [#994](https://github.com/mozilla/nunjucks/pull/994). + +* Fix a bug that caused capturing block tags (e.g. set/endset, + filter/endfilter) to write to the global buffer rather than capturing + their contents. Fixes + [#914](https://github.com/mozilla/nunjucks/issues/914) and + [#972](https://github.com/mozilla/nunjucks/issues/972); merge of + [#990](https://github.com/mozilla/nunjucks/pull/990). Thanks [Noah + Lange](@noahlange). + 3.0.0 (Nov 5 2016) ---------------- diff --git a/browser/nunjucks-slim.js b/browser/nunjucks-slim.js index 0ab25cf0..04248673 100644 --- a/browser/nunjucks-slim.js +++ b/browser/nunjucks-slim.js @@ -1,4 +1,4 @@ -/*! Browser bundle of nunjucks 3.0.0 (slim, only works with precompiled templates) */ +/*! Browser bundle of nunjucks 3.0.1 (slim, only works with precompiled templates) */ (function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); @@ -53,13 +53,13 @@ return /******/ (function(modules) { // webpackBootstrap /************************************************************************/ /******/ ([ /* 0 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { 'use strict'; var lib = __webpack_require__(1); var env = __webpack_require__(2); - var Loader = __webpack_require__(14); + var Loader = __webpack_require__(15); var loaders = __webpack_require__(3); var precompile = __webpack_require__(3); @@ -79,7 +79,7 @@ return /******/ (function(modules) { // webpackBootstrap module.exports.lib = lib; module.exports.nodes = __webpack_require__(3); - module.exports.installJinjaCompat = __webpack_require__(15); + module.exports.installJinjaCompat = __webpack_require__(16); // A single instance of an environment, since this is so commonly used @@ -143,9 +143,9 @@ return /******/ (function(modules) { // webpackBootstrap } -/***/ }, +/***/ }), /* 1 */ -/***/ function(module, exports) { +/***/ (function(module, exports) { 'use strict'; @@ -448,9 +448,9 @@ return /******/ (function(modules) { // webpackBootstrap }; -/***/ }, +/***/ }), /* 2 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { 'use strict'; @@ -469,7 +469,7 @@ return /******/ (function(modules) { // webpackBootstrap // Unconditionally load in this loader, even if no other ones are // included (possible in the slim browser build) - builtin_loaders.PrecompiledLoader = __webpack_require__(13); + builtin_loaders.PrecompiledLoader = __webpack_require__(14); // If the user is using the async API, *always* call it // asynchronously even if the template was synchronous. @@ -1047,15 +1047,15 @@ return /******/ (function(modules) { // webpackBootstrap }; -/***/ }, +/***/ }), /* 3 */ -/***/ function(module, exports) { +/***/ (function(module, exports) { -/***/ }, +/***/ }), /* 4 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -1125,9 +1125,9 @@ return /******/ (function(modules) { // webpackBootstrap }; -/***/ }, +/***/ }), /* 5 */ -/***/ function(module, exports) { +/***/ (function(module, exports) { /* WEBPACK VAR INJECTION */(function(global) {"use strict"; @@ -1207,9 +1207,12 @@ return /******/ (function(modules) { // webpackBootstrap // Safari 6 and 6.1 for desktop, iPad, and iPhone are the only browsers that // have WebKitMutationObserver but not un-prefixed MutationObserver. - // Must use `global` instead of `window` to work in both frames and web + // Must use `global` or `self` instead of `window` to work in both frames and web // workers. `global` is a provision of Browserify, Mr, Mrs, or Mop. - var BrowserMutationObserver = global.MutationObserver || global.WebKitMutationObserver; + + /* globals self */ + var scope = typeof global !== "undefined" ? global : self; + var BrowserMutationObserver = scope.MutationObserver || scope.WebKitMutationObserver; // MutationObservers are desirable because they have high priority and work // reliably everywhere they are implemented. @@ -1352,9 +1355,9 @@ return /******/ (function(modules) { // webpackBootstrap /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) -/***/ }, +/***/ }), /* 6 */ -/***/ function(module, exports) { +/***/ (function(module, exports) { 'use strict'; @@ -1422,9 +1425,9 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = extend(Object, 'Object', {}); -/***/ }, +/***/ }), /* 7 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { 'use strict'; @@ -1439,9 +1442,7 @@ return /******/ (function(modules) { // webpackBootstrap } var filters = { - abs: function(n) { - return Math.abs(n); - }, + abs: Math.abs, batch: function(arr, linecount, fill_with) { var i; @@ -2021,9 +2022,9 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = filters; -/***/ }, +/***/ }), /* 8 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { 'use strict'; @@ -2389,9 +2390,9 @@ return /******/ (function(modules) { // webpackBootstrap }; -/***/ }, +/***/ }), /* 9 */ -/***/ function(module, exports) { +/***/ (function(module, exports) { 'use strict'; @@ -2474,9 +2475,9 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = globals; -/***/ }, +/***/ }), /* 10 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/* WEBPACK VAR INJECTION */(function(setImmediate, process) {// MIT license (by Elan Shanker). (function(globals) { @@ -2562,17 +2563,13 @@ return /******/ (function(modules) { // webpackBootstrap } })(this); - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(11).setImmediate, __webpack_require__(3))) + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(11).setImmediate, __webpack_require__(13))) -/***/ }, +/***/ }), /* 11 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { - /* WEBPACK VAR INJECTION */(function(setImmediate, clearImmediate) {var nextTick = __webpack_require__(12).nextTick; var apply = Function.prototype.apply; - var slice = Array.prototype.slice; - var immediateIds = {}; - var nextImmediateId = 0; // DOM APIs, for completeness @@ -2583,7 +2580,11 @@ return /******/ (function(modules) { // webpackBootstrap return new Timeout(apply.call(setInterval, window, arguments), clearInterval); }; exports.clearTimeout = - exports.clearInterval = function(timeout) { timeout.close(); }; + exports.clearInterval = function(timeout) { + if (timeout) { + timeout.close(); + } + }; function Timeout(id, clearFn) { this._id = id; @@ -2617,139 +2618,218 @@ return /******/ (function(modules) { // webpackBootstrap } }; - // That's not how node.js implements it but the exposed api is the same. - exports.setImmediate = typeof setImmediate === "function" ? setImmediate : function(fn) { - var id = nextImmediateId++; - var args = arguments.length < 2 ? false : slice.call(arguments, 1); - - immediateIds[id] = true; - - nextTick(function onNextTick() { - if (immediateIds[id]) { - // fn.call() is faster so we optimize for the common use-case - // @see http://jsperf.com/call-apply-segu - if (args) { - fn.apply(null, args); - } else { - fn.call(null); - } - // Prevent ids from leaking - exports.clearImmediate(id); - } - }); - - return id; - }; + // setimmediate attaches itself to the global object + __webpack_require__(12); + exports.setImmediate = setImmediate; + exports.clearImmediate = clearImmediate; - exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function(id) { - delete immediateIds[id]; - }; - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(11).setImmediate, __webpack_require__(11).clearImmediate)) -/***/ }, +/***/ }), /* 12 */ -/***/ function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { - // shim for using process in browser + /* WEBPACK VAR INJECTION */(function(global, process) {(function (global, undefined) { + "use strict"; - var process = module.exports = {}; - var queue = []; - var draining = false; - var currentQueue; - var queueIndex = -1; - - function cleanUpNextTick() { - draining = false; - if (currentQueue.length) { - queue = currentQueue.concat(queue); - } else { - queueIndex = -1; + if (global.setImmediate) { + return; } - if (queue.length) { - drainQueue(); + + var nextHandle = 1; // Spec says greater than zero + var tasksByHandle = {}; + var currentlyRunningATask = false; + var doc = global.document; + var registerImmediate; + + function setImmediate(callback) { + // Callback can either be a function or a string + if (typeof callback !== "function") { + callback = new Function("" + callback); + } + // Copy function arguments + var args = new Array(arguments.length - 1); + for (var i = 0; i < args.length; i++) { + args[i] = arguments[i + 1]; + } + // Store and register the task + var task = { callback: callback, args: args }; + tasksByHandle[nextHandle] = task; + registerImmediate(nextHandle); + return nextHandle++; } - } - function drainQueue() { - if (draining) { - return; + function clearImmediate(handle) { + delete tasksByHandle[handle]; } - var timeout = setTimeout(cleanUpNextTick); - draining = true; - var len = queue.length; - while(len) { - currentQueue = queue; - queue = []; - while (++queueIndex < len) { - if (currentQueue) { - currentQueue[queueIndex].run(); + function run(task) { + var callback = task.callback; + var args = task.args; + switch (args.length) { + case 0: + callback(); + break; + case 1: + callback(args[0]); + break; + case 2: + callback(args[0], args[1]); + break; + case 3: + callback(args[0], args[1], args[2]); + break; + default: + callback.apply(undefined, args); + break; + } + } + + function runIfPresent(handle) { + // From the spec: "Wait until any invocations of this algorithm started before this one have completed." + // So if we're currently running a task, we'll need to delay this invocation. + if (currentlyRunningATask) { + // Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a + // "too much recursion" error. + setTimeout(runIfPresent, 0, handle); + } else { + var task = tasksByHandle[handle]; + if (task) { + currentlyRunningATask = true; + try { + run(task); + } finally { + clearImmediate(handle); + currentlyRunningATask = false; + } } } - queueIndex = -1; - len = queue.length; } - currentQueue = null; - draining = false; - clearTimeout(timeout); - } - process.nextTick = function (fun) { - var args = new Array(arguments.length - 1); - if (arguments.length > 1) { - for (var i = 1; i < arguments.length; i++) { - args[i - 1] = arguments[i]; + function installNextTickImplementation() { + registerImmediate = function(handle) { + process.nextTick(function () { runIfPresent(handle); }); + }; + } + + function canUsePostMessage() { + // The test against `importScripts` prevents this implementation from being installed inside a web worker, + // where `global.postMessage` means something completely different and can't be used for this purpose. + if (global.postMessage && !global.importScripts) { + var postMessageIsAsynchronous = true; + var oldOnMessage = global.onmessage; + global.onmessage = function() { + postMessageIsAsynchronous = false; + }; + global.postMessage("", "*"); + global.onmessage = oldOnMessage; + return postMessageIsAsynchronous; } } - queue.push(new Item(fun, args)); - if (queue.length === 1 && !draining) { - setTimeout(drainQueue, 0); + + function installPostMessageImplementation() { + // Installs an event handler on `global` for the `message` event: see + // * https://developer.mozilla.org/en/DOM/window.postMessage + // * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages + + var messagePrefix = "setImmediate$" + Math.random() + "$"; + var onGlobalMessage = function(event) { + if (event.source === global && + typeof event.data === "string" && + event.data.indexOf(messagePrefix) === 0) { + runIfPresent(+event.data.slice(messagePrefix.length)); + } + }; + + if (global.addEventListener) { + global.addEventListener("message", onGlobalMessage, false); + } else { + global.attachEvent("onmessage", onGlobalMessage); + } + + registerImmediate = function(handle) { + global.postMessage(messagePrefix + handle, "*"); + }; } - }; - // v8 likes predictible objects - function Item(fun, array) { - this.fun = fun; - this.array = array; - } - Item.prototype.run = function () { - this.fun.apply(null, this.array); - }; - process.title = 'browser'; - process.browser = true; - process.env = {}; - process.argv = []; - process.version = ''; // empty string to avoid regexp issues - process.versions = {}; - - function noop() {} - - process.on = noop; - process.addListener = noop; - process.once = noop; - process.off = noop; - process.removeListener = noop; - process.removeAllListeners = noop; - process.emit = noop; - - process.binding = function (name) { - throw new Error('process.binding is not supported'); - }; + function installMessageChannelImplementation() { + var channel = new MessageChannel(); + channel.port1.onmessage = function(event) { + var handle = event.data; + runIfPresent(handle); + }; - process.cwd = function () { return '/' }; - process.chdir = function (dir) { - throw new Error('process.chdir is not supported'); - }; - process.umask = function() { return 0; }; + registerImmediate = function(handle) { + channel.port2.postMessage(handle); + }; + } + + function installReadyStateChangeImplementation() { + var html = doc.documentElement; + registerImmediate = function(handle) { + // Create a