Merge pull request #5 from Hao19911125/codex/fix-ena-ejs-warning

Avoid misleading Ena planner EJS warnings
This commit is contained in:
Hao19911125
2026-04-07 12:21:19 +08:00
committed by GitHub

View File

@@ -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 {