mikser-io-render-liquid 4.2.0 → 4.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mikser-io-render-liquid",
3
- "version": "4.2.0",
3
+ "version": "4.2.1",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -114,3 +114,50 @@ describe('liquid parseReferences: shape', () => {
114
114
  }
115
115
  })
116
116
  })
117
+
118
+ // Aliases nested more than one level deep.
119
+ //
120
+ // A read is only useful as provenance if it names the SOURCE path. Each of
121
+ // these rebinds a value to a new name, twice, and the recorded path has to
122
+ // survive both hops — a contract naming `field.label` describes nothing a
123
+ // document author can act on.
124
+ describe('liquid parseReferences: aliases through nesting', () => {
125
+ it('follows a loop binding inside a loop', () => {
126
+ const r = parseReferences(
127
+ '{% for case in data.meta.results.cases %}'
128
+ + '{% for spec in case.specs %}{{ spec.name }}{% endfor %}'
129
+ + '{% endfor %}')
130
+ assert.ok(r.variables.includes('data.meta.results.cases[].specs[].name'),
131
+ `got: ${r.variables.join(', ')}`)
132
+ assert.ok(!r.variables.some(v => v.startsWith('spec.')), 'the local name must not survive')
133
+ })
134
+
135
+ it('follows a loop binding through an assign and back into a loop', () => {
136
+ const r = parseReferences(
137
+ '{% assign block = data.meta.enquiry %}'
138
+ + '{% for field in block.fields %}{{ field.label }}{{ field.type }}{% endfor %}')
139
+ assert.ok(r.variables.includes('data.meta.enquiry.fields[].label'),
140
+ `got: ${r.variables.join(', ')}`)
141
+ assert.ok(r.variables.includes('data.meta.enquiry.fields[].type'))
142
+ })
143
+
144
+ it('resolves a render argument written inside two loops', () => {
145
+ const r = parseReferences(
146
+ '{% for group in data.meta.groups %}'
147
+ + '{% for item in group.items %}'
148
+ + "{% render 'ui/tag', label: item.title %}"
149
+ + '{% endfor %}{% endfor %}')
150
+ const args = r.partials.find(p => p.name === 'ui/tag')?.args ?? {}
151
+ assert.deepEqual(args, { label: 'data.meta.groups[].items[].title' })
152
+ })
153
+
154
+ it('resolves an argument whose value is itself an alias', () => {
155
+ const r = parseReferences(
156
+ '{% assign hero = data.meta.hero %}'
157
+ + "{% render 'ui/tags', tags: hero.tags, rows: hero.tagRows %}")
158
+ const args = r.partials.find(p => p.name === 'ui/tags')?.args ?? {}
159
+ assert.deepEqual(args, { tags: 'data.meta.hero.tags', rows: 'data.meta.hero.tagRows' })
160
+ assert.ok(r.variables.includes('data.meta.hero.tags'))
161
+ assert.ok(r.variables.includes('data.meta.hero.tagRows'))
162
+ })
163
+ })