mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
ui: fix codeLang-sub-select
This commit is contained in:
1 parent
41f6149359
commit
5fad63a3e1
4 files changed
+9
-7
No files matched your search
@@ -1,8 +1,11 @@
|
||||
/**
|
||||
* @param {string} str
|
||||
* @param {any} obj
|
||||
* @returns {string}
|
||||
*/
|
||||
export default function substitute(str, obj) {
|
||||
return str.replace(/\{([^{}]+)\}/g, (match, key) => {
|
||||
if (obj[key] !== undefined) {
|
||||
return String(obj[key]);
|
||||
}
|
||||
if (obj[key] !== undefined) return obj[key].toString();
|
||||
return `{${key}}`;
|
||||
});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user