模板引擎
function tmpl(str, o) {
return str.replace(/\\?\{([^{}] )\}/g, function (match, name) {
return (o[name] === undefined) ? '' : o[name];
});
}
调用示例
var html = tmpl(html, { user_id: user_id, user_name: user_name });
更多专业前端知识,请上 【猿2048】www.mk2048.com