From ffbc9910274b6eab226eb0a20faacf5fcd43843b Mon Sep 17 00:00:00 2001 From: Jacob Mischka Date: Mon, 9 Oct 2017 21:05:59 -0500 Subject: [PATCH] Add missing runtime test, add contexts to SSR --- .../server-side-rendering/visitors/EachBlock.ts | 6 ++++++ .../each-block-destructured-array/_config.js | 13 +++++++++++++ .../samples/each-block-destructured-array/main.html | 3 +++ 3 files changed, 22 insertions(+) create mode 100644 test/runtime/samples/each-block-destructured-array/_config.js create mode 100644 test/runtime/samples/each-block-destructured-array/main.html 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}}