diff --git a/src/generators/server-side-rendering/index.ts b/src/generators/server-side-rendering/index.ts index 37bf859da7..c998cb894b 100644 --- a/src/generators/server-side-rendering/index.ts +++ b/src/generators/server-side-rendering/index.ts @@ -114,7 +114,6 @@ export default function ssr( } var result = { head: '', addComponent }; - ${templateProperties.store && `options.store = %store();`} var html = ${name}._render(result, state, options); var cssCode = Array.from(components).map(c => c.css && c.css.code).filter(Boolean).join('\\n'); @@ -130,6 +129,7 @@ export default function ssr( } ${name}._render = function(__result, state, options) { + ${templateProperties.store && `options.store = %store();`} __result.addComponent(${name}); state = Object.assign(${initialState.join(', ')}); diff --git a/test/runtime/samples/store-nested/Nested.html b/test/runtime/samples/store-nested/Nested.html new file mode 100644 index 0000000000..01662eceac --- /dev/null +++ b/test/runtime/samples/store-nested/Nested.html @@ -0,0 +1,13 @@ +

Hello, {{$name}}!

+ + diff --git a/test/runtime/samples/store-nested/_config.js b/test/runtime/samples/store-nested/_config.js new file mode 100644 index 0000000000..bad5ddeffb --- /dev/null +++ b/test/runtime/samples/store-nested/_config.js @@ -0,0 +1,7 @@ +export default { + store: true, // TODO remove this in v2 + + html: ` +

Hello, world!

+ `, +}; diff --git a/test/runtime/samples/store-nested/main.html b/test/runtime/samples/store-nested/main.html new file mode 100644 index 0000000000..a1e069b2a1 --- /dev/null +++ b/test/runtime/samples/store-nested/main.html @@ -0,0 +1,11 @@ + + +