Skip to content

Commit 02dfadb

Browse files
Merge pull request #93 from onebesky/feature/render-custom-layout
fix issue with custom layout attributes being ignored
2 parents 7421bef + 729b6ad commit 02dfadb

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

src/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ class ExpressVueRenderer {
4646
// Options.mergeDataObject(data);
4747
if (vueOptions) {
4848
Options.vue = Models.Defaults.mergeObjects(Options.vue, vueOptions);
49+
if (vueOptions.layout) {
50+
Options.layout = Models.Defaults.mergeObjects(Options.layout, vueOptions.layout);
51+
}
4952
}
5053
Options.component = componentPath;
5154

tests/index.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,36 @@ test('renders App object', t => {
3434
t.fail(error.stack);
3535
});
3636
});
37+
38+
39+
test('renders App object with custom layout', t => {
40+
const vueOptionsWithLayout = {
41+
layout: {
42+
html: {
43+
start: 'html-start',
44+
end: 'html-end',
45+
},
46+
body: {
47+
start: 'body-start',
48+
end: 'body-end'
49+
},
50+
template: {
51+
start: "template-start",
52+
end: "template-end"
53+
},
54+
}
55+
};
56+
const renderer = new ExpressVueRenderer(options);
57+
return renderer.createAppObject('main', data, vueOptionsWithLayout)
58+
.then(app => {
59+
t.is(app.template.html.start, "html-start");
60+
t.is(app.template.html.end, "html-end");
61+
t.is(app.template.body.start, "body-start");
62+
t.is(app.template.body.end, "body-end");
63+
t.is(app.template.template.start, "template-start");
64+
t.is(app.template.template.end, "template-end");
65+
})
66+
.catch(error => {
67+
t.fail(error.stack);
68+
});
69+
});

0 commit comments

Comments
 (0)