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)
})
.then((html) => {
scope.pop()
scope.pop(hash)
scope.opts.blocks = originBlocks
scope.opts.blockMode = originBlockMode
return html
+1 -3
View File
@@ -38,14 +38,12 @@ module.exports = function (liquid) {
return liquid.getTemplate(layout, scope.opts.root)
})
.then(templates => {
// push the hash
scope.push(hash)
scope.opts.blockMode = 'output'
return liquid.renderer.renderTemplates(templates, scope)
})
// pop the hash
.then(partial => {
scope.pop()
scope.pop(hash)
return partial
})
}
+2 -3
View File
@@ -43,11 +43,10 @@ module.exports = function (liquid) {
// build array of arguments to pass to sequential promises...
collection = collection.slice(offset, offset + limit)
if (!cols) cols = collection.length
var contexts = []
collection.some((item, i) => {
var contexts = collection.map((item, i) => {
var ctx = {}
ctx[this.variable] = item
contexts.push(ctx)
return ctx
})
return mapSeries(contexts,
+1
View File
@@ -1,3 +1,4 @@
'use strict'
const chai = require('chai')
const expect = chai.expect