Fixed templates
All checks were successful
Build / Publish Docs (push) Successful in 58s
Build / Build NPM Project (push) Successful in 1m15s
Build / Tag Version (push) Successful in 11s

This commit is contained in:
2025-12-06 21:51:47 -05:00
parent 32c61fff42
commit 1b05af09fb
2 changed files with 2 additions and 2 deletions

View File

@@ -1,6 +1,6 @@
{ {
"name": "@ztimson/utils", "name": "@ztimson/utils",
"version": "0.27.18", "version": "0.27.19",
"description": "Utility library", "description": "Utility library",
"author": "Zak Timson", "author": "Zak Timson",
"license": "MIT", "license": "MIT",

View File

@@ -24,7 +24,7 @@ export async function renderTemplate(template: string, data: any, fetch?: (file:
const evaluate = (code: string, data: object, fatal = true) => { const evaluate = (code: string, data: object, fatal = true) => {
try { try {
return Function('data', `Object.assign(this, data); return ${code};`)(data); return Function('data', `with(data) { return ${code}; }`)(data);
} catch { } catch {
if(fatal) throw new TemplateError(`Failed to evaluate: ${code}`); if(fatal) throw new TemplateError(`Failed to evaluate: ${code}`);
else return false; else return false;