mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 04:10:40 -07:00
feature: plugin API, working on #86
This commit is contained in:
@@ -12,6 +12,24 @@ describe('Liquid', function () {
|
||||
}).to.throw(/illegal root/)
|
||||
})
|
||||
})
|
||||
describe('#plugin()', function () {
|
||||
it('should call plugin on the instance', async function () {
|
||||
const engine = new Liquid()
|
||||
engine.plugin(function (Liquid) {
|
||||
this.registerFilter('foo', x => `foo${x}foo`)
|
||||
})
|
||||
const html = await engine.parseAndRender('{{"bar"|foo}}')
|
||||
expect(html).to.equal('foobarfoo')
|
||||
})
|
||||
it('should call plugin with Liquid', async function () {
|
||||
const engine = new Liquid()
|
||||
engine.plugin(function (Liquid) {
|
||||
this.registerFilter('t', x => Liquid.isFalsy(x))
|
||||
})
|
||||
const html = await engine.parseAndRender('{{false|t}}')
|
||||
expect(html).to.equal('true')
|
||||
})
|
||||
})
|
||||
describe('#express()', function () {
|
||||
const liquid = new Liquid({root: '/root'})
|
||||
const render = liquid.express()
|
||||
|
||||
Reference in New Issue
Block a user