mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 10:26:08 +01:00 
			
		
		
		
	always use template strings instead of string concatenation
This commit is contained in:
		| @@ -36,7 +36,9 @@ function executeBundle(bundle, apiParams = {}) { | ||||
|     cls.set('bundleNoteId', bundle.note.noteId); | ||||
|  | ||||
|     // last \r\n is necessary if script contains line comment on its last line | ||||
|     const script = "function() {\r\n" + bundle.script + "\r\n}"; | ||||
|     const script = `function() {\r | ||||
| ${bundle.script}\r | ||||
| }`; | ||||
|     const ctx = new ScriptContext(bundle.allNotes, apiParams); | ||||
|  | ||||
|     try { | ||||
| @@ -166,15 +168,13 @@ function getScriptBundle(note, root = true, scriptEnv = null, includedNoteIds = | ||||
|     if (note.isJavaScript()) { | ||||
|         bundle.script += ` | ||||
| apiContext.modules['${note.noteId}'] = { exports: {} }; | ||||
| ${root ? 'return ' : ''}${isFrontend ? 'await' : ''} ((${isFrontend ? 'async' : ''} function(exports, module, require, api` + (modules.length > 0 ? ', ' : '') + | ||||
|             modules.map(child => sanitizeVariableName(child.title)).join(', ') + `) { | ||||
| ${root ? 'return ' : ''}${isFrontend ? 'await' : ''} ((${isFrontend ? 'async' : ''} function(exports, module, require, api${modules.length > 0 ? ', ' : ''}${modules.map(child => sanitizeVariableName(child.title)).join(', ')}) { | ||||
| try { | ||||
| ${backendOverrideContent || note.getContent()}; | ||||
| } catch (e) { throw new Error("Load of script note \\"${note.title}\\" (${note.noteId}) failed with: " + e.message); } | ||||
| for (const exportKey in exports) module.exports[exportKey] = exports[exportKey]; | ||||
| return module.exports; | ||||
| }).call({}, {}, apiContext.modules['${note.noteId}'], apiContext.require(${JSON.stringify(moduleNoteIds)}), apiContext.apis['${note.noteId}']` + (modules.length > 0 ? ', ' : '') + | ||||
|             modules.map(mod => `apiContext.modules['${mod.noteId}'].exports`).join(', ') + `)); | ||||
| }).call({}, {}, apiContext.modules['${note.noteId}'], apiContext.require(${JSON.stringify(moduleNoteIds)}), apiContext.apis['${note.noteId}']${modules.length > 0 ? ', ' : ''}${modules.map(mod => `apiContext.modules['${mod.noteId}'].exports`).join(', ')})); | ||||
| `; | ||||
|     } | ||||
|     else if (note.isHtml()) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user