/**
* 根据模板渲染 字段用 ${} 包含,例如 let obj={a:"你好"}, tpl = "${a}" renderTemplete(tpl,{a}) = "你好"
* @param {String} tpl
* @param {Object} obj
*/
export const renderTemplate = (tpl, obj) => {
if (!Object[Symbol.hasInstance](obj)) {
return "";
}
return tpl.replace(/${S*?}/gi, match => {
const key = match.replace(/${/, "").replace(/}/, "");
return get(obj, key);
});
};