Browse Source

fix: mustache replacer

Ahmad Kholid 3 years ago
parent
commit
dfdd8a6eab

+ 5 - 1
src/background/workflowEngine/blocksHandler/handlerJavascriptCode.js

@@ -21,7 +21,11 @@ export async function javascriptCode({ outputs, data, ...block }, { refData }) {
       }
     }
 
-    const result = await this._sendMessageToTab({ ...block, data, refData });
+    const payload = { ...block, data, refData: { variables: {} } };
+    if (data.code.includes('automaRefData')) payload.refData = refData;
+    console.log(data.code.includes('automaRefData'), payload);
+
+    const result = await this._sendMessageToTab(payload);
 
     if (result) {
       if (result.columns.data?.$error) {

+ 1 - 1
src/utils/referenceData/mustacheReplacer.js

@@ -134,7 +134,7 @@ function replacer(str, { regex, tagLen, modifyPath, data }) {
     }
 
     result = typeof result === 'string' ? result : JSON.stringify(result);
-    replaceResult.list[match] = result;
+    replaceResult.list[match] = result.slice(0, 512);
 
     return result;
   });