You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Hydro/packages/ui-default/utils/substitute.js

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;