From 07c1763b52da6b6bd130c89693036432d05e5054 Mon Sep 17 00:00:00 2001 From: Hao19911125 <99091644+Hao19911125@users.noreply.github.com> Date: Tue, 7 Apr 2026 12:19:33 +0800 Subject: [PATCH] Avoid misleading Ena planner EJS warnings --- ena-planner/ena-planner.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/ena-planner/ena-planner.js b/ena-planner/ena-planner.js index 7f588ed..d14f393 100644 --- a/ena-planner/ena-planner.js +++ b/ena-planner/ena-planner.js @@ -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 = '') { const labelSuffix = templateLabel ? ` (${templateLabel})` : ''; + if (shouldSkipSyncEjsPreRender(template)) { + return template; + } + // Try window.ejs first (ST loads this library) if (window.ejs?.render) { try {