admin/lib/notificationTemplate.ts
alisaza e1eaf5eff5 feat: initial ghabilee-admin backoffice app
Extract admin dashboard from ghabilee-frontend2 into a dedicated Next.js
app for backoffice.ghabilee.ir (no SEO indexing / Clarity).
2026-09-05 13:12:59 +03:30

10 lines
498 B
TypeScript

export const renderNotificationTemplate = (template: string, variables: Record<string, string>) =>
template.replace(/\{\{([a-zA-Z0-9_]+)\}\}/g, (_match, key: string) => variables[key] ?? `{{${key}}}`)
export const renderNotificationActionUrlPreview = (template: string, variables: Record<string, string>) =>
template.replace(/\{\{([a-zA-Z0-9_]+)\}\}/g, (_match, key: string) => {
const value = variables[key]
return value === undefined ? `{{${key}}}` : encodeURIComponent(value)
})