mde / ejs

Embedded JavaScript templates -- http://ejs.co
Apache License 2.0
7.7k stars 841 forks source link

ejs raises error when include in for loop #695

Closed TrueXPixells closed 1 year ago

TrueXPixells commented 1 year ago

code;

    <% rand.forEach(function (x) { %>
    <%- await include("util/botcard", {bot: x}) %>
    <%})%>

raises

SyntaxError: missing ) after argument list in ./views/index.ejs while compiling ejs

but this code not raises error;

    <% rand.forEach(function (x) { %>
    <%- include("util/botcard", {bot: x}) %>
    <%})%>

my ejs render;

            const standole = await ejs.renderFile("", {}, { async: true });
            res.send(standole);
mde commented 1 year ago

I'm not certain about the specific error you're seeing, but for starters, forEach does not work with await. And I'd have to go back to the code to be sure, but I don't think include is async in the first place?

TrueXPixells commented 1 year ago

i dont know but ejs has a LOT OF issuses; i solved this problem but include renders html to last point (with await loop, bad eng im sry) ok. im closing this issuse

mde commented 1 year ago

Again, this is not any sort of issue with EJS. There is an extensive suite of tests we run for every release, and millions of installations every week. There are a tiny number of reported issues, and these types of problems are almost always in the userland code.