mirror of
https://github.com/fosrl/pangolin.git
synced 2026-02-02 08:09:10 +00:00
18 lines
366 B
TypeScript
18 lines
366 B
TypeScript
export function replacePlaceholder(
|
|
stringWithPlaceholder: string,
|
|
data: Record<string, string>
|
|
) {
|
|
let newString = stringWithPlaceholder;
|
|
|
|
const keys = Object.keys(data);
|
|
|
|
for (const key of keys) {
|
|
newString = newString.replace(
|
|
new RegExp(`{{${key}}}`, "gm"),
|
|
data[key]
|
|
);
|
|
}
|
|
|
|
return newString;
|
|
}
|