From 79d1af0c5fef3138d82933cdbc75aec2ea81cf6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abdussamed=20ULUTA=C5=9E?= Date: Tue, 25 Oct 2022 01:10:27 +0300 Subject: [PATCH] blade --- Processor/File.js | 5 +++-- Processor/Parse.js | 9 +++++++-- source/abc.blade.php.cache | Bin 872 -> 872 bytes source/abc.blade.php.js | 2 +- target/abc.html | 2 +- test.js | 2 +- 6 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Processor/File.js b/Processor/File.js index 371c523..a27ac6f 100644 --- a/Processor/File.js +++ b/Processor/File.js @@ -30,13 +30,14 @@ File.prototype.isRequiredRebuild = function(content){ }; File.prototype.execute = function(memoriable){ let output = []; - let t = new vm.Script(this.parsedContent,{ + let t = new vm.Script(this.parsedContent.ast,{ cachedData: this.cachedData, }); let content = vm.createContext({ ...memoriable, output, - echo:(...args) => output.push(...args) + echo:(...args) => output.push(...args), + _external: e => {} }); t.runInContext(content); this.cachedData = t.createCachedData(); diff --git a/Processor/Parse.js b/Processor/Parse.js index dddf075..2bf3e68 100644 --- a/Processor/Parse.js +++ b/Processor/Parse.js @@ -7,6 +7,7 @@ function ParseEngine(file) { let content = []; let buffer = []; + let requiredImports = []; let hmx = new Hemex(); hmx.setText(file.content); function flushBuffer() @@ -319,7 +320,8 @@ function ParseEngine(file) break; } case "import":{ - jsContent.push(`output.push(${JSON.stringify(``)});\n`); + requiredImports.push(value); + jsContent.push(`_external(${value});\n`); break; } case "js-if-block":{ @@ -341,7 +343,10 @@ function ParseEngine(file) } return jsContent.join(''); } - return useAST(content); + return { + ast:useAST(content), + requiredImports + }; }; module.exports = ParseEngine; \ No newline at end of file diff --git a/source/abc.blade.php.cache b/source/abc.blade.php.cache index d191d40e3d41276942db76c96babab691407a936..2b1b19fa39f38974ddc753d206d2adbfddf301d4 100644 GIT binary patch delta 372 zcmaFC_JXZmlI7lkcPV$*EM{b2IO#a$LjW@agTda2C`OrJMi=%K2@F6G2*ivUK43Nn zh|Lq2xbN=&YivMverZWTX$eHED$z%o1t?ZfTATr-7#M2;Ym8WYEfQd4v-B3AZPG(hX;c6=EC%f1STJ1OJ6+s45PZPGDr~%69cD=AOqJN z4lv~dChsuvGjK$Jm^=+Yj{`yWWCbQCSyrw?!fXcxt+<_02EG)0_-!A1i;!D7}!J{7+3@nfEXgc=)k^}gM)z)=#Wb*I}c5M#bnEP NV6q0Y0}B@r002IJT@nBQ delta 371 zcmaFC_JXZmlI7lkcPV$*>}F(OIO#a$LjW@a!@7OPco}7a89mrnBrpI$I1n?c_<-5$ zAU026;yRJcL^dEhzqF*Fv;-nnXJ+2T0u(DKEzST^42(5_weyOS5*`EDHi|C(&LNQj zt_m3?xjA;cTs9zDVPgGNiDOrSO+d!_rWR!+CM7a3$^@pqdwTBQDlPUwlLERsWOoxP755)fb@tsQ%F2DvB;5od4fnjnp zld%CPtQZB@XC(1~?PXwK6LDZ*5ddN+pV5JRD+dSIL0rpxTqi$cvSr*eS%ujF0CQ|# AL;wH) diff --git a/source/abc.blade.php.js b/source/abc.blade.php.js index 2480b78..986a8b3 100644 --- a/source/abc.blade.php.js +++ b/source/abc.blade.php.js @@ -1,5 +1,5 @@ output.push("\r\n\r\n\r\n \r\n \r\n \r\n \r\n "); output.push( "Merhaba" ); output.push("\r\n \r\n\r\n\r\n "); -output.push(""); +_external("merhaba"); output.push("\r\n\r\n"); diff --git a/target/abc.html b/target/abc.html index 71d6fc6..1dbfd93 100644 --- a/target/abc.html +++ b/target/abc.html @@ -9,6 +9,6 @@ - + \ No newline at end of file diff --git a/test.js b/test.js index 695f5a3..51c2360 100644 --- a/test.js +++ b/test.js @@ -4,7 +4,7 @@ let {writeFile} = require("node:fs/promises"); async function main() { let node = await parser.processFile("./source/abc.blade.php"); - await writeFile("./source/abc.blade.php.js", node.parsedContent, "utf8"); + await writeFile("./source/abc.blade.php.js", node.parsedContent.ast, "utf8"); let result = node.execute({ ebilet: 25 });