fix: prevent $ interpolation in renderTemplate replacement
This commit is contained in:
@@ -35,8 +35,9 @@ function renderTemplate(template, vars) {
|
||||
let { subject, body } = template;
|
||||
for (const [k, v] of Object.entries(vars)) {
|
||||
const re = new RegExp(`\\{\\{${k}\\}\\}`, 'g');
|
||||
subject = subject.replace(re, v || '');
|
||||
body = body.replace(re, v || '');
|
||||
const val = String(v ?? '');
|
||||
subject = subject.replace(re, () => val);
|
||||
body = body.replace(re, () => val);
|
||||
}
|
||||
return { subject, body };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user