From 0a522c880b4a9b9b0f556fc748fb673441a0e3cc Mon Sep 17 00:00:00 2001 From: Ondrej Nebesky Date: Thu, 5 Oct 2017 08:59:53 -0700 Subject: [PATCH] fix issue with custom layout attributes being ignored https://github.com/express-vue/express-vue/issues/126#issuecomment-330141595 --- src/index.js | 3 +++ tests/index.js | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/src/index.js b/src/index.js index e7e506b..95696cb 100644 --- a/src/index.js +++ b/src/index.js @@ -46,6 +46,9 @@ class ExpressVueRenderer { // Options.mergeDataObject(data); if (vueOptions) { Options.vue = Models.Defaults.mergeObjects(Options.vue, vueOptions); + if (vueOptions.layout) { + Options.layout = Models.Defaults.mergeObjects(Options.layout, vueOptions.layout); + } } Options.component = componentPath; diff --git a/tests/index.js b/tests/index.js index 4c1943f..114acb6 100644 --- a/tests/index.js +++ b/tests/index.js @@ -34,3 +34,36 @@ test('renders App object', t => { t.fail(error.stack); }); }); + + +test('renders App object with custom layout', t => { + const vueOptionsWithLayout = { + layout: { + html: { + start: 'html-start', + end: 'html-end', + }, + body: { + start: 'body-start', + end: 'body-end' + }, + template: { + start: "template-start", + end: "template-end" + }, + } + }; + const renderer = new ExpressVueRenderer(options); + return renderer.createAppObject('main', data, vueOptionsWithLayout) + .then(app => { + t.is(app.template.html.start, "html-start"); + t.is(app.template.html.end, "html-end"); + t.is(app.template.body.start, "body-start"); + t.is(app.template.body.end, "body-end"); + t.is(app.template.template.start, "template-start"); + t.is(app.template.template.end, "template-end"); + }) + .catch(error => { + t.fail(error.stack); + }); +}); \ No newline at end of file