fix: block.super with strictVariables, #806 (#807)

This commit is contained in:
Yang Jun
2025-05-15 01:47:57 +08:00
committed by GitHub
parent 2f414f8e40
commit 025c40f0f2
4 changed files with 32 additions and 4 deletions
+20
View File
@@ -101,6 +101,26 @@ describe('tags/layout', function () {
const output = '<link href="base.css" rel="stylesheet"><link href="extra.css" rel="stylesheet">'
return expect(html).toBe(output)
})
it('should pass block.super as a string', async function () {
mock({
'/parent.html': '{% block css %}<link href="base.css" rel="stylesheet">{% endblock %}'
})
const src = '{% layout "parent.html" %}' +
'{%block css%}{{block.super}}<meta basesize={{block.super | size}}>{%endblock%}'
const html = await liquid.parseAndRender(src)
const output = '<link href="base.css" rel="stylesheet"><meta basesize=39>'
return expect(html).toBe(output)
})
it('should support block.super while strictVariables', async function () {
mock({
'/parent.html': '{% block css %}<link href="base.css" rel="stylesheet">{% endblock %}'
})
const src = '{% layout "parent.html" %}' +
'{%block css%}{{block.super}}<link href="extra.css" rel="stylesheet">{%endblock%}'
const html = await liquid.parseAndRender(src, undefined, { strictVariables: true })
const output = '<link href="base.css" rel="stylesheet"><link href="extra.css" rel="stylesheet">'
return expect(html).toBe(output)
})
it('should render block.super to empty if no parent exists', async function () {
mock({
'/parent.html': '{% block css %}{{block.super}}<link href="base.css" rel="stylesheet">{% endblock %}'