fix: type compatible with v9 tag definition, support Context as scope in various render APIs, #570

This commit is contained in:
Jun Yang
2022-12-18 12:48:06 +08:00
parent 7526d4062d
commit fb6a9f8717
5 changed files with 55 additions and 20 deletions
+9
View File
@@ -57,6 +57,10 @@ describe('Liquid', function () {
const html = await engine.parseAndRender(src, { foo: Promise.resolve('FOO') })
expect(html).to.equal('FOO')
})
it('should parse and render with Context', async function () {
const html = await engine.parseAndRender('{{foo}}', new Context({ foo: 'FOO' }))
expect(html).to.equal('FOO')
})
})
describe('#parseAndRenderSync', function () {
const engine = new Liquid()
@@ -145,6 +149,11 @@ describe('Liquid', function () {
const str = await engine.evalValue('"foo"', ctx)
expect(str).to.equal('foo')
})
it('should support plain scope', async function () {
const engine = new Liquid()
const str = await engine.evalValue('foo', { foo: 'FOO' })
expect(str).to.equal('FOO')
})
})
describe('#evalValueSync', function () {
it('should eval string literal', function () {