feat: globals shared between tags, see #185

This commit is contained in:
harttle
2020-02-08 04:59:23 +08:00
parent fc0cf6fe7b
commit 870e7ec6aa
4 changed files with 29 additions and 9 deletions
+13
View File
@@ -76,6 +76,19 @@ describe('tags/render', function () {
return expect(html).to.equal('InParent: harttle InChild: ')
})
it('should be able to access globals', async function () {
mock({
'/hash.html': 'InParent: {{name}} {% render "user.html" %}',
'/user.html': 'InChild: {{name}}'
})
const html = await liquid.renderFile('hash.html', {
name: 'harttle'
}, {
globals: { name: 'Harttle' }
})
return expect(html).to.equal('InParent: harttle InChild: Harttle')
})
it('should support render: with', async function () {
mock({
'/with.html': '{% render "color" with "red", shape: "rect" %}',