mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-16 12:50:38 -07:00
feat: support {{block.super}}, see #38
This commit is contained in:
@@ -69,6 +69,36 @@ describe('tags/layout', function () {
|
||||
const html = await liquid.parseAndRender(src)
|
||||
return expect(html).to.equal('XAYBZ')
|
||||
})
|
||||
it('should support block.super', 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)
|
||||
const output = '<link href="base.css" rel="stylesheet"><link href="extra.css" rel="stylesheet">'
|
||||
return expect(html).to.equal(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 %}'
|
||||
})
|
||||
const src = '{% layout "parent.html" %}' +
|
||||
'{%block css%}{{block.super}}<link href="extra.css" rel="stylesheet">{%endblock%}'
|
||||
const html = await liquid.parseAndRender(src)
|
||||
const output = '<link href="base.css" rel="stylesheet"><link href="extra.css" rel="stylesheet">'
|
||||
return expect(html).to.equal(output)
|
||||
})
|
||||
it('should support nested block.super', async function () {
|
||||
mock({
|
||||
'/root.html': '{% block css %}<link href="root.css" rel="stylesheet">{% endblock %}',
|
||||
'/parent.html': '{% layout "root.html" %}{% block css %}{{block.super}}<link href="parent.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)
|
||||
const output = '<link href="root.css" rel="stylesheet"><link href="parent.css" rel="stylesheet"><link href="extra.css" rel="stylesheet">'
|
||||
return expect(html).to.equal(output)
|
||||
})
|
||||
it('should support variable as layout name', async function () {
|
||||
mock({
|
||||
'/parent.html': 'X{% block "a"%}{% endblock %}Y'
|
||||
|
||||
Reference in New Issue
Block a user