monorepo packages (#344)
This commit is contained in:
12
projects/app/src/utils/common/tools/text.ts
Normal file
12
projects/app/src/utils/common/tools/text.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
replace {{variable}} to value
|
||||
*/
|
||||
export function replaceVariable(text: string, obj: Record<string, string>) {
|
||||
for (const key in obj) {
|
||||
const val = obj[key];
|
||||
if (typeof val !== 'string') continue;
|
||||
|
||||
text = text.replace(new RegExp(`{{(${key})}}`, 'g'), val);
|
||||
}
|
||||
return text || '';
|
||||
}
|
||||
Reference in New Issue
Block a user