You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello all, was hoping someone can help me understand how I can override or use client:true callback function to fetch the include from database.
To give context, we are using Kotlin and GraalVM to run its JavaScript interpreter with EJS 3.1.8.
Here is what I have tried thus far:
letdata={};letstr="Hello <%= include('./src/main/resources/ejs_templates/imports/imports.ejs', {}); %>";varfn=ejs.compile(str,{client:true});fn(data,null,function(path,d){// include callbackprint("HELLO WORLD!!!!!")// THIS PRINTSprint(path)// THIS PRINTSvarincludedTemplate=fileReader.test3(path);// This is a custom we created that reads the data and we have printed this out, and is workingreturnincludedTemplate;});// returns rendered stringvarrendered=fn(data);
however, var rendered = fn(data); is stating: undefined is not a function.
We were thinking this could be an issue because we are technically doing this server side; however, we are specifying client: true so we have also tried this:
print("I'm here");// tried overriding how it fetches for the include fileejs.includeFile=function(path,d){print("Did we reach the mecca?")returnfileReader.test3(path);}// also tried this override just in caseejs.include=function(path,d){print("Did we reach the mecca?")returnfileReader.test3(path);}letdata={};letstr="<%= include('./src/main/resources/ejs_templates/imports/imports.ejs', {});%>";varfn=ejs.compile(str);varrendered=fn.apply(data);
When we execute this we get:
Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed: org.graalvm.polyglot.PolyglotException: Error: Could not find the include file "./src/main/resources/ejs_templates/imports/imports.ejs"] with root cause
org.graalvm.polyglot.PolyglotException: Error: Could not find the include file "./src/main/resources/ejs_templates/imports/imports.ejs"
Which to me means, we are not overriding the include fetch appropriately and its using the EJS default include fetch.
Does anyone have any thoughts on how could accomplish this?
The text was updated successfully, but these errors were encountered:
I am a dummy, it ended up being because I am not setting fn to anything...
letdata={}letstr="<%= include('./src/main/resources/ejs_templates/imports/imports.ejs');%>";varfn=ejs.compile(str,{client:true});varrendered=fn(data,null,function(path,d){// include callback logicvarincludedTemplate=fileReader.test3(path);print(includedTemplate)returnincludedTemplate;},null);
Hello all, was hoping someone can help me understand how I can override or use client:true callback function to fetch the include from database.
To give context, we are using Kotlin and GraalVM to run its JavaScript interpreter with EJS 3.1.8.
Here is what I have tried thus far:
however,
var rendered = fn(data);
is stating: undefined is not a function.if I print just fn, the content is:
so it is a function...
We were thinking this could be an issue because we are technically doing this server side; however, we are specifying
client: true
so we have also tried this:When we execute this we get:
Which to me means, we are not overriding the include fetch appropriately and its using the EJS default include fetch.
Does anyone have any thoughts on how could accomplish this?
The text was updated successfully, but these errors were encountered: