Skip to content

Commit eabc563

Browse files
authored
Merge pull request #17 from qial/issues/16
Fixed issues with JSON properties
2 parents 68f5ee4 + b1a2d66 commit eabc563

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

lib/functions.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -860,8 +860,12 @@ const f = {
860860
var collection = content.ele(key).att('jcr:primaryType','nt:unstructured')
861861
for(var i = 0; i < value.length; i++) {
862862
var children = collection.ele(key+i).att('jcr:primaryType','nt:unstructured')
863-
for (childKey in value[i])
864-
children.att(childKey, value[i][childKey])
863+
for (childKey in value[i]) {
864+
if(value[i][childKey].startsWith('{'))
865+
children.att(childkey, '\\' + value[i][childKey])
866+
else
867+
children.att(childKey, value[i][childKey])
868+
}
865869
}
866870
} else {
867871
content.att(key,value)
@@ -891,11 +895,18 @@ const f = {
891895
var collection = versionContent.ele(key).att('jcr:primaryType','nt:unstructured')
892896
for(var i = 0; i < value.length; i++) {
893897
var children = collection.ele(key+i).att('jcr:primaryType','nt:unstructured')
894-
for (childKey in value[i])
895-
children.att(childKey, value[i][childKey])
898+
for (childKey in value[i]) {
899+
if(value[i][childKey].startsWith('{'))
900+
children.att(childkey, '\\' + value[i][childKey])
901+
else
902+
children.att(childKey, value[i][childKey])
903+
}
896904
}
897905
} else {
898-
versionContent.att(key,value)
906+
if(value.toString().startsWith('{'))
907+
versionContent.att(key,'\\' + value)
908+
else
909+
versionContent.att(key, value)
899910
}
900911
}
901912
return xml

lib/htmltovue.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ function htmltovue(name, container, compile, deploy, dialog, model, vue, samplee
120120

121121
const templateVue = fs.readFileSync(path.join(componentPath, 'template.vue')).toString()
122122
const newTemplateVue = templateVue.replace(/^<template>[\s\S]*^<\/template>/m, out).replace(/&apos;/g, '\'')
123-
if ((convertVue && templateVue.valueOf() !== newTemplateVue.valueOf()) || (convertVue && !fs.existsSync(path.join(uiAppsComponentPath, 'template.vue')))) {
123+
const uiAppsTemplatePath = path.join(uiAppsComponentPath, 'template.vue')
124+
const uiAppsTemplateMatches = fs.existsSync(uiAppsTemplatePath) && fs.readFileSync(uiAppsTemplatePath).toString().valueOf() === templateVue.valueOf()
125+
if ((convertVue && templateVue.valueOf() !== newTemplateVue.valueOf()) || (convertVue && !uiAppsTemplateMatches)) {
124126
fs.writeFileSync(path.join(componentPath, 'template.vue'), newTemplateVue)
125127

126128
// copy template.vue file to component

0 commit comments

Comments
 (0)