mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 04:10:40 -07:00
refactor: minimize PR diff noise
Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -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
@@ -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, {}) }))
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user