87,910
社区成员
发帖
与我相关
我的任务
分享
var json = {name: "流火", blog: "ued.t"};
function sub(str, data){
return str.replace(/{(.*?)}/igm, function($, $1){
return data[$1]?data[$1]:$;
});
}
var tpl = '{name} (blog: {blog})';
var html = sub(tpl, json);