@ztimson/utils 0.27.17 → 0.27.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2308,7 +2308,7 @@ async function renderTemplate(template, data, fetch2) {
|
|
|
2308
2308
|
};
|
|
2309
2309
|
const evaluate = (code, data2, fatal = true) => {
|
|
2310
2310
|
try {
|
|
2311
|
-
return Function("data", `
|
|
2311
|
+
return Function("data", `with(data) { return ${code}; }`)(data2);
|
|
2312
2312
|
} catch {
|
|
2313
2313
|
if (fatal) throw new TemplateError(`Failed to evaluate: ${code}`);
|
|
2314
2314
|
else return false;
|
|
@@ -2344,7 +2344,7 @@ async function renderTemplate(template, data, fetch2) {
|
|
|
2344
2344
|
content = content.replace(found[0], evaluate(found[1].trim(), d) || "");
|
|
2345
2345
|
}
|
|
2346
2346
|
while (!!(found = /\{\{\s*?>\s*?(.+?):(.+?)\s*?}}([\s\S]*?)\{\{\s*?\/>\s*?}}/g.exec(content))) {
|
|
2347
|
-
content = content.replace(found[0], await renderTemplate(await fetch2(found[1].trim), {
|
|
2347
|
+
content = content.replace(found[0], await renderTemplate(await fetch2(found[1].trim()), {
|
|
2348
2348
|
...data,
|
|
2349
2349
|
[found[2].trim()]: found[3]
|
|
2350
2350
|
}, fetch2));
|