feat: support offset:continue, see #439

This commit is contained in:
Harttle
2022-01-20 00:12:18 +08:00
committed by Harttle
parent 388d0fbbc4
commit 8c27a84059
4 changed files with 144 additions and 34 deletions
+5
View File
@@ -47,7 +47,11 @@ export default {
return
}
const continueKey = 'continue-' + this.variable + '-' + this.collection.getText()
ctx.push({ continue: ctx.getRegister(continueKey) })
const hash = yield this.hash.render(ctx)
ctx.pop()
const modifiers = this.liquid.options.orderedFilterParameters
? Object.keys(hash).filter(x => MODIFIERS.includes(x))
: MODIFIERS.filter(x => hash[x] !== undefined)
@@ -58,6 +62,7 @@ export default {
return reversed(collection)
}, collection)
ctx.setRegister(continueKey, (hash['offset'] || 0) + collection.length)
const scope = { forloop: new ForloopDrop(collection.length, this.collection.getText(), this.variable) }
ctx.push(scope)
for (const item of collection) {