fix: bundle pi dependency and directive handling

This commit is contained in:
Peter Steinberger
2025-12-06 00:49:46 +01:00
parent 6f27f742fe
commit ddfb76e9e0
8 changed files with 127 additions and 115 deletions

View File

@@ -21,7 +21,8 @@ export type TemplateContext = MsgContext & {
};
// Simple {{Placeholder}} interpolation using inbound message context.
export function applyTemplate(str: string, ctx: TemplateContext) {
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);