Skip to content

Commit 36d2249

Browse files
authored
Merge pull request #26 from oslabs-beta/keyla/debugCodeSnippet
Keyla/debug code snippet
2 parents 386910f + 4ecd84c commit 36d2249

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

src/components/right-sidebar/CodeSnippet.vue

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ export default {
8686
},
8787
// Creates <template> boilerplate
8888
writeTemplateTag(componentName, activeComponent) {
89-
// console.log(this.activeComponentObj)
9089
const htmlElementMap = {
9190
div: ["<div", "</div>"],
9291
button: ["<button", "</button>"],
@@ -128,11 +127,11 @@ export default {
128127
} else {
129128
nestedString += htmlElementMap[child.text][0];
130129
if (child.class !== "") {
131-
nestedString += " " + "class = " + `"${child.class}"`;
130+
nestedString += " " + "class=" + `"${child.class}"`;
132131
}
133132
if (child.binding !== "") {
134133
if (child.text !== 'img' || child.text !== 'link') {
135-
nestedString += ` v-model = "${child.binding}"`
134+
nestedString += ` v-model="${child.binding}"`
136135
137136
}
138137
}
@@ -165,16 +164,16 @@ export default {
165164
outputStr += htmlElementMap[el.text][0]
166165
//if conditional to check class
167166
if (el.class !== "") {
168-
outputStr += " " + "class = " + `"${el.class}"`;
167+
outputStr += " " + "class=" + `"${el.class}"`;
168+
}
169+
170+
if (el.binding !== "") {
171+
outputStr += ` v-model="${el.binding}"`
169172
}
170173
// add an extra slash at the end for child Components and single tags
171174
if(childComponents.includes(el.text) || el.text === "img" || el.text === "input" || el.text === "link"){
172175
outputStr += "/"
173176
}
174-
175-
if (el.binding !== "") {
176-
outputStr += ` v-model = "${el.binding}"`
177-
}
178177
outputStr += ">";
179178
if (el.children.length) {
180179
outputStr += "\n";
@@ -227,30 +226,31 @@ export default {
227226
// if true add data section and populate with props
228227
let data = "";
229228
if (this.componentMap[this.activeComponent].props.length) {
230-
data += " data () {\n return {";
229+
data += " props: {";
231230
this.componentMap[this.activeComponent].props.forEach((prop) => {
232-
data += `\n ${prop}: "PLACEHOLDER FOR VALUE",`;
231+
data += `\n ${prop}: "PLACEHOLDER FOR VALUE",`;
233232
});
234233
data += "\n";
235-
data += " }\n";
234+
//data += " }\n";
236235
data += " },\n";
237236
}
238237
const htmlBinding = this.componentMap[this.activeComponent].htmlList
239238
240-
data += " data () {\n return {\n"
239+
data += " data() {\n return {\n"
241240
htmlBinding.forEach(el => {
242241
if (el.binding !== '') {
243-
data += ` "${el.binding}": "PLACEHOLDER FOR VALUE", `
242+
data += ` "${el.binding}": "PLACEHOLDER FOR VALUE", `
244243
data += '\n'
245244
}
246245
})
247-
data += ` \n } \n `
246+
data += ` }`
247+
data += ` \n }, \n `
248248
249249
250250
// if true add computed section and populate with state
251251
let computed = "";
252252
if (this.componentMap[this.activeComponent].state.length) {
253-
computed += " computed: {";
253+
computed += " computed: {";
254254
computed += "\n ...mapState([";
255255
this.componentMap[this.activeComponent].state.forEach((state) => {
256256
computed += `\n "${state}", `;
@@ -299,7 +299,7 @@ export default {
299299
output += imports + "\nexport default defineComponent ({\n name: '" + componentName + "';";
300300
} else {
301301
output = "\n\n<script>\n";
302-
output += imports + "\nexport default {\n name: '" + componentName + "';";
302+
output += imports + "\nexport default {\n name: '" + componentName + "'";
303303
}
304304
output += ",\n components: {\n";
305305
output += childrenComponentNames + " },\n";

0 commit comments

Comments
 (0)