Extract admin dashboard from ghabilee-frontend2 into a dedicated Next.js app for backoffice.ghabilee.ir (no SEO indexing / Clarity).
11 lines
431 B
TypeScript
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)
|
|
})
|