admin/texts/format.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

11 lines
431 B
TypeScript

/**
* Replaces `{key}` placeholders in a copy string with values from `vars`.
* Missing keys leave the placeholder intact so broken templates stay visible in UI/tests.
*/
export const format = (template: string, vars: Record<string, string | number>): string =>
template.replace(/\{(\w+)\}/g, (match, key: string) => {
const value = vars[key]
return value === undefined || value === null ? match : String(value)
})