refactor: minimize PR diff noise

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
Yang Jun
2026-07-14 21:52:55 +08:00
co-authored by Cursor
parent 708280b1c8
commit 8aa8f73e02
3 changed files with 4 additions and 4 deletions
+2 -1
View File
@@ -2,6 +2,7 @@ import { Context } from '../context'
import { HTMLToken, TagToken } from '../tokens'
import { Render } from './render'
import { Tag, HTML } from '../template'
import { SimpleEmitter } from '../emitters'
import { toPromise } from '../util'
describe('render', function () {
@@ -14,7 +15,7 @@ describe('render', function () {
it('should render html', async function () {
const scope = new Context()
const token = { getContent: () => '<p>' } as HTMLToken
const html = await toPromise(render.renderTemplates([new HTML(token)], scope))
const html = await toPromise(render.renderTemplates([new HTML(token)], scope, new SimpleEmitter()))
return expect(html).toBe('<p>')
})
})
+1 -1
View File
@@ -41,7 +41,7 @@ export default class extends Tag {
stream.start()
}
* render (ctx: Context, emitter: Emitter): Generator<unknown, unknown, unknown> {
* render (ctx: Context, emitter: Emitter): Generator<unknown, void | string, Template[]> {
const r = this.liquid.renderer
const continueKey = 'continue-' + this.variable + '-' + this.collection.getText()
ctx.push(createScope({ continue: ctx.getRegister(continueKey, {}) }))
+1 -2
View File
@@ -39,10 +39,9 @@ export default class extends Tag {
}
* render (ctx: Context, emitter: Emitter): Generator<unknown, void, unknown> {
let collection = toEnumerable(yield evalToken(this.collection, ctx))
const args = (yield this.args.render(ctx)) as Record<string, any>
const offset = args.offset || 0
let collection = toEnumerable(yield evalToken(this.collection, ctx))
const limit = (args.limit === undefined) ? collection.length : args.limit
collection = collection.slice(offset, offset + limit)