@@ -22,13 +22,11 @@ import { useExportComponent } from "../composables/useExportComponent.js";
2222import { mapState } from " vuex" ;
2323const { fs , ipcRenderer } = window ;
2424
25- import writeNested from " ../../mixins/writeNested" ;
26- import { result } from " lodash" ;
25+ // import writeNested from "../../mixins/writeNested";
2726
2827
2928export default {
3029 name: " ExportProjectComponent" ,
31- mixins: [writeNested],
3230 methods: {
3331 useExportComponentBound () {
3432 useExportComponent .bind (this )();
@@ -227,7 +225,42 @@ test('renders ${componentName}', () => {
227225 `
228226 </el-badge>` ],
229227 };
230-
228+ // function to loop through nested elements
229+ function writeNested (childrenArray , indent ) {
230+ if (! childrenArray .length ) {
231+ return " " ;
232+ }
233+ let indented = indent + " " ;
234+ let nestedString = " " ;
235+
236+ childrenArray .forEach ((child ) => {
237+ nestedString += indented;
238+ if (! child .text ) {
239+ nestedString += ` <${ child} />\n ` ;
240+ } else {
241+ nestedString += htmlElementMap[child .text ][0 ];
242+ if (child .class !== " " ) {
243+ nestedString += " " + " class = " + ` "${ child .class } "` ;
244+ }
245+ if (child .binding !== " " ) {
246+ nestedString += " " + " v-model = " + ` "${ child .binding } "` ;
247+ }
248+ if (child .text === " img" || child .text === " input" || child .text === " link" ) {
249+ nestedString += " />" ;
250+ } else { nestedString += " >" ; }
251+
252+ if (child .children .length ) {
253+ nestedString += " \n " ;
254+ nestedString += writeNested (child .children , indented);
255+ nestedString += indented + htmlElementMap[child .text ][1 ];
256+ nestedString += " \n " ;
257+ } else {
258+ nestedString += htmlElementMap[child .text ][1 ] + " \n " ;
259+ }
260+ }
261+ });
262+ return nestedString;
263+ }
231264 // iterate through component's htmllist
232265 let htmlArr = this .componentMap [componentName].htmlList ;
233266 let outputStr = ` ` ;
@@ -328,12 +361,18 @@ test('renders ${componentName}', () => {
328361 return ` <template>\n <div id = "${ compID} ">\n ${ templateTagStr}${ routeStr} </div>\n </template>` ;
329362 }
330363 else {
331-
364+ const arrOfChildComp = this .componentMap [componentName].children ;
365+ arrOfChildComp .forEach (childName => {
366+ let childNameClass = this .componentMap [childName].htmlAttributes .class ;
367+ let childNameClassFullStr = (childNameClass === " " ) ? " " : ` class = '${ childNameClass} '` ;
368+ routeStr += ` <${ childName}${ childNameClassFullStr} ></${ childName} >\n `
369+ });
370+
332371 return ` <template>\n <div>\n\t ${ str}${ templateTagStr}${ routeStr} </div>\n </template>` ;
333372 }
334373 }
335374 else {
336- return ` <template>\n\t ${ str}${ templateTagStr}${ routeStr} \t </div>\n </template>`
375+ return ` <template>\n <div> \n \t${ str}${ templateTagStr}${ routeStr} \t </div>\n </template>`
337376 }
338377 },
339378 /**
@@ -366,6 +405,20 @@ test('renders ${componentName}', () => {
366405 }
367406
368407 let childrenComponentNames = " " ;
408+ let childComponentImportNames = " " ;
409+
410+ const arrOfChildComp = this .componentMap [componentName].children ;
411+
412+ arrOfChildComp .forEach (childName => {
413+ // Build child component text string
414+ if (childName !== arrOfChildComp[arrOfChildComp .length - 1 ]){
415+ childrenComponentNames += " " + childName + " ,\n " ;
416+ }
417+ else {
418+ childrenComponentNames += " " + childName + " \n " ;
419+ }
420+ childComponentImportNames += ` import ${ childName} from '../components/${ childName} .vue';\n `
421+ })
369422
370423 let data = " " ;
371424 data += " data () {\n return {" ;
@@ -416,6 +469,8 @@ test('renders ${componentName}', () => {
416469 } else {
417470 output = " \n\n <script>\n " ;
418471
472+ output+= ` \n ${ childComponentImportNames} ` ;
473+
419474 output += imports + " \n export default {\n name: '" + componentName + " '" ;
420475
421476 }
0 commit comments