feat: customize globals & strictVariables when calling render, see #432

This commit is contained in:
Harttle
2021-12-11 20:22:58 +08:00
committed by Harttle
parent 6023d9ba10
commit 6801552fe6
6 changed files with 60 additions and 27 deletions
+9
View File
@@ -43,6 +43,15 @@ describe('Liquid', function () {
const html = await engine.parseAndRender(src, {})
return expect(html).to.equal('12')
})
it('should support `globals` render option', async function () {
const src = '{{ foo }}'
const html = await engine.parseAndRender(src, {}, { globals: { foo: 'FOO' } })
return expect(html).to.equal('FOO')
})
it('should support `strictVariables` render option', function () {
const src = '{{ foo }}'
return expect(engine.parseAndRender(src, {}, { strictVariables: true })).rejectedWith(/undefined variable/)
})
})
describe('#express()', function () {
const liquid = new Liquid({ root: '/root' })