This commit is contained in:
harttle
2017-10-21 10:50:44 +08:00
parent 118624ca7d
commit be17d7443c
4 changed files with 94 additions and 97 deletions
+8 -11
View File
@@ -2092,7 +2092,9 @@ module.exports = function (liquid) {
if (_.isString(collection) && collection.length > 0) { if (_.isString(collection) && collection.length > 0) {
collection = [collection]; collection = [collection];
} else if (_.isObject(collection)) { } else if (_.isObject(collection)) {
collection = Object.keys(collection); collection = Object.keys(collection).map(function (key) {
return [key, collection[key]];
});
} }
} }
if (!Array.isArray(collection) || !collection.length) { if (!Array.isArray(collection) || !collection.length) {
@@ -2210,7 +2212,6 @@ var withRE = new RegExp('with\\s+(' + lexical.value.source + ')');
var assert = require('../src/util/assert.js'); var assert = require('../src/util/assert.js');
module.exports = function (liquid) { module.exports = function (liquid) {
liquid.registerTag('include', { liquid.registerTag('include', {
parse: function parse(token) { parse: function parse(token) {
var match = lexical.value.exec(token.args); var match = lexical.value.exec(token.args);
@@ -2296,7 +2297,6 @@ var lexical = Liquid.lexical;
var assert = require('../src/util/assert.js'); var assert = require('../src/util/assert.js');
module.exports = function (liquid) { module.exports = function (liquid) {
liquid.registerTag('layout', { liquid.registerTag('layout', {
parse: function parse(token, remainTokens) { parse: function parse(token, remainTokens) {
var match = lexical.value.exec(token.args); var match = lexical.value.exec(token.args);
@@ -2314,18 +2314,16 @@ module.exports = function (liquid) {
// now register.blocks contains rendered blocks // now register.blocks contains rendered blocks
.then(function () { .then(function () {
return liquid.getTemplate(layout, register.root); return liquid.getTemplate(layout, register.root);
}) }).then(function (templates) {
// push the hash // push the hash
.then(function (templates) { scope.push(hash);
return scope.push(hash), templates;
})
// render the parent // render the parent
.then(function (templates) {
return liquid.renderer.renderTemplates(templates, scope); return liquid.renderer.renderTemplates(templates, scope);
}) })
// pop the hash // pop the hash
.then(function (partial) { .then(function (partial) {
return scope.pop(), partial; scope.pop();
return partial;
}); });
} }
}); });
@@ -2358,9 +2356,8 @@ module.exports = function (liquid) {
register.blocks[_this2.block] = partial; register.blocks[_this2.block] = partial;
return partial; return partial;
}); });
} } else {
// if already defined by desendents // if already defined by desendents
else {
register.blocks[this.block] = html; register.blocks[this.block] = html;
return Promise.resolve(html); return Promise.resolve(html);
} }
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "liquidjs", "name": "liquidjs",
"version": "1.9.6", "version": "1.9.7",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "liquidjs", "name": "liquidjs",
"version": "1.9.6", "version": "1.9.7",
"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": {