mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-28 22:55:14 -07:00
1.9.5
This commit is contained in:
Vendored
+29
-16
@@ -919,7 +919,8 @@ var Scope = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
set: function set(k, v) {
|
set: function set(k, v) {
|
||||||
setPropertyByPath(this.scopes[this.scopes.length - 1], k, v);
|
var scope = this.findScopeFor(k);
|
||||||
|
setPropertyByPath(scope, k, v);
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
push: function push(ctx) {
|
push: function push(ctx) {
|
||||||
@@ -929,6 +930,16 @@ var Scope = {
|
|||||||
pop: function pop() {
|
pop: function pop() {
|
||||||
return this.scopes.pop();
|
return this.scopes.pop();
|
||||||
},
|
},
|
||||||
|
findScopeFor: function findScopeFor(key) {
|
||||||
|
var i = this.scopes.length - 1;
|
||||||
|
while (i >= 0 && !(key in this.scopes[i])) {
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
if (i < 0) {
|
||||||
|
i = this.scopes.length - 1;
|
||||||
|
}
|
||||||
|
return this.scopes[i];
|
||||||
|
},
|
||||||
unshift: function unshift(ctx) {
|
unshift: function unshift(ctx) {
|
||||||
assert(ctx, 'trying to push ' + ctx + ' into scopes');
|
assert(ctx, 'trying to push ' + ctx + ' into scopes');
|
||||||
return this.scopes.unshift(ctx);
|
return this.scopes.unshift(ctx);
|
||||||
@@ -1840,19 +1851,18 @@ var re = new RegExp('(' + lexical.identifier.source + ')\\s*=(.*)');
|
|||||||
var assert = require('../src/util/assert.js');
|
var assert = require('../src/util/assert.js');
|
||||||
|
|
||||||
module.exports = function (liquid) {
|
module.exports = function (liquid) {
|
||||||
|
liquid.registerTag('assign', {
|
||||||
liquid.registerTag('assign', {
|
parse: function parse(token) {
|
||||||
parse: function parse(token) {
|
var match = token.args.match(re);
|
||||||
var match = token.args.match(re);
|
assert(match, 'illegal token ' + token.raw);
|
||||||
assert(match, 'illegal token ' + token.raw);
|
this.key = match[1];
|
||||||
this.key = match[1];
|
this.value = match[2];
|
||||||
this.value = match[2];
|
},
|
||||||
},
|
render: function render(scope) {
|
||||||
render: function render(scope) {
|
scope.set(this.key, liquid.evalOutput(this.value, scope));
|
||||||
scope.set(this.key, liquid.evalOutput(this.value, scope));
|
return Promise.resolve('');
|
||||||
return Promise.resolve('');
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
},{"..":2,"../src/util/assert.js":16,"any-promise":3}],23:[function(require,module,exports){
|
},{"..":2,"../src/util/assert.js":16,"any-promise":3}],23:[function(require,module,exports){
|
||||||
@@ -2114,8 +2124,11 @@ module.exports = function (liquid) {
|
|||||||
|
|
||||||
var html = '';
|
var html = '';
|
||||||
return mapSeries(contexts, function (context) {
|
return mapSeries(contexts, function (context) {
|
||||||
scope.push(context);
|
return Promise.resolve().then(function () {
|
||||||
return liquid.renderer.renderTemplates(_this2.templates, scope).then(function (partial) {
|
return scope.push(context);
|
||||||
|
}).then(function () {
|
||||||
|
return liquid.renderer.renderTemplates(_this2.templates, scope);
|
||||||
|
}).then(function (partial) {
|
||||||
return html += partial;
|
return html += partial;
|
||||||
}).catch(function (e) {
|
}).catch(function (e) {
|
||||||
if (e instanceof RenderBreakError) {
|
if (e instanceof RenderBreakError) {
|
||||||
|
|||||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "liquidjs",
|
"name": "liquidjs",
|
||||||
"version": "1.9.4",
|
"version": "1.9.5",
|
||||||
"description": "A Liquid template engine for Node.js and browsers, with all shopify/liquid features.",
|
"description": "A Liquid template engine for Node.js and browsers, with all shopify/liquid features.",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user