mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-16 21:00:40 -07:00
feat: passing liquid to FilterImpl, closes #277
This commit is contained in:
@@ -54,4 +54,15 @@ describe('Issues', function () {
|
||||
const html = engine.parseAndRenderSync(template, { condition1: true, condition2: true })
|
||||
expect(html).to.equal('<div>Y</div>')
|
||||
})
|
||||
it('#277 Passing liquid in FilterImpl', () => {
|
||||
const engine = new Liquid()
|
||||
engine.registerFilter('render', function (template: string, name: string) {
|
||||
return this.liquid.parseAndRenderSync(decodeURIComponent(template), { name })
|
||||
})
|
||||
const html = engine.parseAndRenderSync(
|
||||
`{{ subtemplate | render: "foo" }}`,
|
||||
{ subtemplate: encodeURIComponent('hello {{ name }}') }
|
||||
)
|
||||
expect(html).to.equal('hello foo')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user