mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-19 06:20:38 -07:00
fix: map filter allow nil results in strict mode, fixes #647
This commit is contained in:
@@ -31,7 +31,10 @@ describe('filter', function () {
|
||||
it('should render a simple filter', async function () {
|
||||
expect(await toPromise(new Filter('upcase', (x: string) => x.toUpperCase(), [], liquid).render('foo', ctx))).toBe('FOO')
|
||||
})
|
||||
|
||||
it('should reject promise when filter throws', async function () {
|
||||
const filter = new Filter('foo', function * () { throw new Error('intended') }, [], liquid)
|
||||
expect(toPromise(filter.render('foo', ctx))).rejects.toMatch('intended')
|
||||
})
|
||||
it('should render filters with argument', async function () {
|
||||
const two = new NumberToken('2', 0, 1, undefined)
|
||||
expect(await toPromise(new Filter('add', (a: number, b: number) => a + b, [two], liquid).render(3, ctx))).toBe(5)
|
||||
|
||||
@@ -27,6 +27,6 @@ export class Filter {
|
||||
if (isKeyValuePair(arg)) argv.push([arg[0], yield evalToken(arg[1], context)])
|
||||
else argv.push(yield evalToken(arg, context))
|
||||
}
|
||||
return this.handler.apply({ context, liquid: this.liquid }, [value, ...argv])
|
||||
return yield this.handler.apply({ context, liquid: this.liquid }, [value, ...argv])
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user