Skip to content

Commit 8f67e46

Browse files
Handle error code-tag is present in a file but file is missing in Common-template
- The if else statements throw an error when replace ejs code-tag is present in the specific file, but the common file is also missing in the common template - This handles the error by just replacing the replace_here tag with an empty string, since this tag is not defined for the second render
1 parent b3a6a3f commit 8f67e46

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/store.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,11 @@ export async function fetchTemplates(template) {
107107
const text_specific = await response.text()
108108
// Dynamically fetch the common templates-code, if the file exists in common,
109109
// then render the replace_here code tag using ejs template
110+
// If the file doesn't exist in common, then it will fetch an empty string
111+
// then the code tag is replaced with empty string
110112
const res_common = await fetch(`${url}/template-common/${filename}`)
111-
if(res_common.ok){
112-
const text_common = await res_common.text()
113-
files[template][filename] = mergeCode(text_specific, text_common)
114-
}
115-
// else move on with the code from the specific file
116-
else{
117-
files[template][filename] = text_specific
118-
}
113+
const text_common = await res_common.text()
114+
files[template][filename] = mergeCode(text_specific, text_common)
119115
}
120116

121117
// calling genCode explicitly here

0 commit comments

Comments
 (0)