refactor: purify task worldinfo and ejs runtime

This commit is contained in:
Youzini-afk
2026-03-27 02:28:34 +08:00
parent c31af1d1a4
commit b915cd07a7
5 changed files with 787 additions and 600 deletions

View File

@@ -129,6 +129,12 @@ try {
if (template === "<% broken") {
throw new Error("Unexpected end of input");
}
if (template === "<% await execute() %>") {
return async function compiled(locals) {
await locals.execute();
return "";
};
}
return async function compiled(locals) {
return [
locals.charName,
@@ -167,6 +173,13 @@ try {
);
assert.deepEqual(compileCalls, ["<%= 1 %>", "<%= 1 %>"]);
await assert.rejects(
() => evalTaskEjsTemplate("<% await execute() %>", renderCtx),
(error) =>
error?.code === "st_bme_task_ejs_unsupported_helper" &&
error?.helperName === "execute",
);
const syntaxError = await checkTaskEjsSyntax("<% broken");
assert.equal(syntaxError, "Unexpected end of input");