mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 04:10:40 -07:00
fix: allow {%render%} to reassign argument, #404
This commit is contained in:
committed by
Harttle
parent
432d1c7ccb
commit
124f4c4485
@@ -69,6 +69,11 @@ describe('tags/assign', function () {
|
||||
const html = await liquid.parseAndRender(src)
|
||||
return expect(html).to.equal('-6')
|
||||
})
|
||||
it('should allow reassignment', async function () {
|
||||
const src = '{% assign var = 1 %}{% assign var = 2 %}{{ var }}'
|
||||
const html = await liquid.parseAndRender(src)
|
||||
return expect(html).to.equal('2')
|
||||
})
|
||||
describe('scope', function () {
|
||||
it('should read from parent scope', async function () {
|
||||
const src = '{%for a in (1..2)%}{{num}}{%endfor%}'
|
||||
|
||||
@@ -19,7 +19,7 @@ describe('tags/capture', function () {
|
||||
return expect(html).to.equal('A')
|
||||
})
|
||||
|
||||
it('should shading rather than overwriting', async function () {
|
||||
it('should not change root scope', async function () {
|
||||
const src = '{% capture var %}10{% endcapture %}{{var}}'
|
||||
const ctx = { 'var': 20 }
|
||||
const html = await liquid.parseAndRender(src, ctx)
|
||||
|
||||
@@ -39,7 +39,7 @@ describe('tags/increment', function () {
|
||||
return expect(html).to.equal('012 10')
|
||||
})
|
||||
|
||||
it('should not shading capture', async function () {
|
||||
it('should not hide capture', async function () {
|
||||
const src = '{% capture var %}10{% endcapture %}{% increment var %}{% increment var %}{% increment var %} {{var}}'
|
||||
const html = await liquid.parseAndRender(src)
|
||||
return expect(html).to.equal('012 10')
|
||||
|
||||
@@ -86,6 +86,16 @@ describe('tags/render', function () {
|
||||
expect(html).to.equal('InParent: harttle InChild: ')
|
||||
})
|
||||
|
||||
it('should allow argument reassignment', async function () {
|
||||
mock({
|
||||
'/parent.html': '{% render child.html, color: "red" %}',
|
||||
'/child.html': '{% assign color = "green" %}{{ color }}'
|
||||
})
|
||||
const staticLiquid = new Liquid({ dynamicPartials: false, root: '/' })
|
||||
const html = await staticLiquid.renderFile('parent.html')
|
||||
return expect(html).to.equal('green')
|
||||
})
|
||||
|
||||
it('should be able to access globals', async function () {
|
||||
liquid = new Liquid({ root: '/', extname: '.html', globals: { name: 'Harttle' } })
|
||||
mock({
|
||||
|
||||
Reference in New Issue
Block a user