mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
9 lines
205 B
JavaScript
9 lines
205 B
JavaScript
export default function substitute(str, obj) {
|
|
return str.replace(/\{([^{}]+)\}/g, (match, key) => {
|
|
if (obj[key] !== undefined) {
|
|
return String(obj[key]);
|
|
}
|
|
return `{${key}}`;
|
|
});
|
|
}
|