mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-16 21:00:40 -07:00
fix: allow quotes in inline comment tag, fixes #628
This commit is contained in:
@@ -431,4 +431,27 @@ describe('Issues', function () {
|
||||
const fn = () => engine.parseAndRenderSync("{%- assign module = '' | split '' -%}")
|
||||
expect(fn).toThrow(/expected ":" after filter name/)
|
||||
})
|
||||
it('#628 Single or double quote breaks comments', () => {
|
||||
const template = `{%- liquid
|
||||
# Show a message that's customized to the product type
|
||||
|
||||
assign product_type = product.type | downcase
|
||||
assign message = ''
|
||||
|
||||
case product_type
|
||||
when 'health'
|
||||
assign message = 'This is a health potion!'
|
||||
when 'love'
|
||||
assign message = 'This is a love potion!'
|
||||
else
|
||||
assign message = 'This is a potion!'
|
||||
endcase
|
||||
|
||||
echo message
|
||||
-%}`
|
||||
const engine = new Liquid()
|
||||
const product = { type: 'love' }
|
||||
const result = engine.parseAndRenderSync(template, { product })
|
||||
expect(result).toEqual('This is a love potion!')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -17,6 +17,16 @@ describe('tags/inline-comment', function () {
|
||||
const html = await liquid.parseAndRender(src)
|
||||
return expect(html).toBe('foo')
|
||||
})
|
||||
it('should allow single quotes', async function () {
|
||||
const src = "B{% # that's %}A"
|
||||
const html = await liquid.parseAndRender(src)
|
||||
return expect(html).toBe('BA')
|
||||
})
|
||||
it('should allow double quotes', async function () {
|
||||
const src = 'B{% # that"s %}A'
|
||||
const html = await liquid.parseAndRender(src)
|
||||
return expect(html).toBe('BA')
|
||||
})
|
||||
it('should handle hash without trailing whitespace', async function () {
|
||||
const src = '{% #some comment %}'
|
||||
const html = await liquid.parseAndRender(src)
|
||||
|
||||
Reference in New Issue
Block a user