diff --git a/src/generators/server-side-rendering/visitors/EachBlock.ts b/src/generators/server-side-rendering/visitors/EachBlock.ts index 10565f6bf2..09342bf26b 100644 --- a/src/generators/server-side-rendering/visitors/EachBlock.ts +++ b/src/generators/server-side-rendering/visitors/EachBlock.ts @@ -18,6 +18,12 @@ export default function visitEachBlock( const contexts = new Map(block.contexts); contexts.set(node.context, node.context); + if (node.destructuredContexts) { + for (const i = 0; i < node.destructuredContexts.length; i++) { + contexts.set(node.destructuredContexts[i], `${node.context}[${i}]`); + } + } + const indexes = new Map(block.indexes); if (node.index) indexes.set(node.index, node.context); diff --git a/test/runtime/samples/each-block-destructured-array/_config.js b/test/runtime/samples/each-block-destructured-array/_config.js new file mode 100644 index 0000000000..ab7bcfe1b7 --- /dev/null +++ b/test/runtime/samples/each-block-destructured-array/_config.js @@ -0,0 +1,13 @@ +export default { + data: { + animalPaws: { + raccoon: 'hands', + eagle: 'wings' + } + }, + + html: ` +
raccoon: hands
+eagle: wings
+ ` +}; diff --git a/test/runtime/samples/each-block-destructured-array/main.html b/test/runtime/samples/each-block-destructured-array/main.html new file mode 100644 index 0000000000..ec553692c8 --- /dev/null +++ b/test/runtime/samples/each-block-destructured-array/main.html @@ -0,0 +1,3 @@ +{{#each Object.entries(animalPaws) as [animal, pawType]}} +{{animal}}: {{pawType}}
+{{/each}}