mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-19 14:30:38 -07:00
feat: add layouts, partials apart from root, #395
This commit is contained in:
@@ -76,6 +76,15 @@ describe('tags/layout', function () {
|
||||
const html = await liquid.parseAndRender(src)
|
||||
return expect(html).to.equal('XAYBZ')
|
||||
})
|
||||
it('should support `options.layouts`', async () => {
|
||||
mock({
|
||||
'/layouts/parent.html': 'X{% block "a"%}{%endblock%}Y'
|
||||
})
|
||||
const src = '{% layout "parent.html" %}{%block a%}A{%endblock%}'
|
||||
const liquid = new Liquid({ layouts: '/layouts' })
|
||||
const html = await liquid.parseAndRender(src)
|
||||
return expect(html).to.equal('XAY')
|
||||
})
|
||||
it('should support block.super', async function () {
|
||||
mock({
|
||||
'/parent.html': '{% block css %}<link href="base.css" rel="stylesheet">{% endblock %}'
|
||||
@@ -171,7 +180,7 @@ describe('tags/layout', function () {
|
||||
})
|
||||
|
||||
describe('static partial', function () {
|
||||
it('should support filename with extention', async function () {
|
||||
it('should support filename with extension', async function () {
|
||||
mock({
|
||||
'/parent.html': '{{color}}{%block%}{%endblock%}',
|
||||
'/main.html': '{% layout parent.html color:"black"%}{%block%}A{%endblock%}'
|
||||
|
||||
@@ -21,6 +21,15 @@ describe('tags/render', function () {
|
||||
const html = await liquid.renderFile('/current.html')
|
||||
expect(html).to.equal('barfoobar')
|
||||
})
|
||||
it('should support render', async function () {
|
||||
mock({
|
||||
'/current.html': 'bar{% render "foo.html" %}bar',
|
||||
'/partials/foo.html': 'foo'
|
||||
})
|
||||
const liquid = new Liquid({ partials: '/partials' })
|
||||
const html = await liquid.renderFile('/current.html')
|
||||
expect(html).to.equal('barfoobar')
|
||||
})
|
||||
it('should support template string', async function () {
|
||||
mock({
|
||||
'/current.html': 'bar{% render "bar/{{name}}" %}bar',
|
||||
|
||||
Reference in New Issue
Block a user