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