模板引擎
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 });
模板引擎
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 });