Skip to content

Commit 63c79f8

Browse files
committed
CodeSnipper now updates if Child Component is added to the htmlList
1 parent d3ad957 commit 63c79f8

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/components/right-sidebar/CodeSnippet.vue

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,8 @@ export default {
8585
else return `<template>\n <div>\n${templateTagStr} </div>\n</template>`;
8686
},
8787
// Creates <template> boilerplate
88-
writeTemplateTag(componentName) {
88+
writeTemplateTag(componentName, activeComponent) {
8989
// console.log(this.activeComponentObj)
90-
// create reference object
9190
const htmlElementMap = {
9291
div: ["<div", "</div>"],
9392
button: ["<button", "</button>"],
@@ -110,6 +109,9 @@ export default {
110109
h5: ["<h5", "</h5>"],
111110
h6: ["<h6", "</h6>"],
112111
};
112+
this.componentMap[this.activeComponent].children.forEach(child => {
113+
htmlElementMap[child]=[`<${child}`, ""] //single
114+
})
113115
function writeNested(childrenArray, indent) {
114116
if (!childrenArray.length) {
115117
return "";
@@ -157,6 +159,11 @@ export default {
157159
if (el.class !== "") {
158160
outputStr += " " + "class = " + `"${el.class}"`;
159161
}
162+
// add an extra slash at the end for child Components
163+
if(this.componentMap[this.activeComponent].children.includes(el.text)){
164+
outputStr += "/"
165+
}
166+
160167
outputStr += ">";
161168
if (el.children.length) {
162169
outputStr += "\n";

0 commit comments

Comments
 (0)