refactor: lint cleanups and helpers
This commit is contained in:
@@ -25,7 +25,7 @@ export type TemplateContext = MsgContext & {
|
||||
export function applyTemplate(str: string | undefined, ctx: TemplateContext) {
|
||||
if (!str) return "";
|
||||
return str.replace(/{{\s*(\w+)\s*}}/g, (_, key) => {
|
||||
const value = (ctx as Record<string, unknown>)[key];
|
||||
return value == null ? "" : String(value);
|
||||
const value = ctx[key as keyof TemplateContext];
|
||||
return value ?? "";
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user