mirror of
https://github.com/Youzini-afk/ST-Bionic-Memory-Ecology.git
synced 2026-05-15 22:30:38 +08:00
Merge pull request #5 from Hao19911125/codex/fix-ena-ejs-warning
Avoid misleading Ena planner EJS warnings
This commit is contained in:
@@ -799,9 +799,26 @@ function buildEjsContext() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function shouldSkipSyncEjsPreRender(template) {
|
||||||
|
const src = String(template ?? '');
|
||||||
|
if (!src.includes('<%')) return false;
|
||||||
|
|
||||||
|
// Planner worldbook entries are rendered again later with ST's async EJS env.
|
||||||
|
// Skip the lightweight sync pre-pass for async templates/helpers so we don't
|
||||||
|
// emit misleading warnings for entries that will render correctly downstream.
|
||||||
|
if (/\bawait\b/.test(src)) return true;
|
||||||
|
if (/\b(getwi|getWorldInfo|evalTemplate)\s*\(/.test(src)) return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
function renderEjsTemplate(template, ctx, templateLabel = '') {
|
function renderEjsTemplate(template, ctx, templateLabel = '') {
|
||||||
const labelSuffix = templateLabel ? ` (${templateLabel})` : '';
|
const labelSuffix = templateLabel ? ` (${templateLabel})` : '';
|
||||||
|
|
||||||
|
if (shouldSkipSyncEjsPreRender(template)) {
|
||||||
|
return template;
|
||||||
|
}
|
||||||
|
|
||||||
// Try window.ejs first (ST loads this library)
|
// Try window.ejs first (ST loads this library)
|
||||||
if (window.ejs?.render) {
|
if (window.ejs?.render) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user