refactor: pop the same context as the pushed one

This commit is contained in:
harttle
2018-07-21 17:12:46 +08:00
parent 63b5658604
commit 36f84e4b3c
4 changed files with 5 additions and 7 deletions
+1 -1
View File
@@ -42,7 +42,7 @@ module.exports = function (liquid) {
return liquid.renderer.renderTemplates(templates, scope) return liquid.renderer.renderTemplates(templates, scope)
}) })
.then((html) => { .then((html) => {
scope.pop() scope.pop(hash)
scope.opts.blocks = originBlocks scope.opts.blocks = originBlocks
scope.opts.blockMode = originBlockMode scope.opts.blockMode = originBlockMode
return html return html
+1 -3
View File
@@ -38,14 +38,12 @@ module.exports = function (liquid) {
return liquid.getTemplate(layout, scope.opts.root) return liquid.getTemplate(layout, scope.opts.root)
}) })
.then(templates => { .then(templates => {
// push the hash
scope.push(hash) scope.push(hash)
scope.opts.blockMode = 'output' scope.opts.blockMode = 'output'
return liquid.renderer.renderTemplates(templates, scope) return liquid.renderer.renderTemplates(templates, scope)
}) })
// pop the hash
.then(partial => { .then(partial => {
scope.pop() scope.pop(hash)
return partial return partial
}) })
} }
+2 -3
View File
@@ -43,11 +43,10 @@ module.exports = function (liquid) {
// build array of arguments to pass to sequential promises... // build array of arguments to pass to sequential promises...
collection = collection.slice(offset, offset + limit) collection = collection.slice(offset, offset + limit)
if (!cols) cols = collection.length if (!cols) cols = collection.length
var contexts = [] var contexts = collection.map((item, i) => {
collection.some((item, i) => {
var ctx = {} var ctx = {}
ctx[this.variable] = item ctx[this.variable] = item
contexts.push(ctx) return ctx
}) })
return mapSeries(contexts, return mapSeries(contexts,
+1
View File
@@ -1,3 +1,4 @@
'use strict'
const chai = require('chai') const chai = require('chai')
const expect = chai.expect const expect = chai.expect