花瓣这样的模板引擎纯手写的吗

下面是花瓣的一个模板引擎,是不是先写成html再用什么工具能生成
(function(rt){
vartemplates=rt.templates,
attrs=function(){
returnrt.attrs.apply(rt,arguments)
},_=function(){
returnrt._.apply(rt,arguments)
},img=function(){
returnrt.img.apply(rt,arguments)
},imgURL=function(){
returnrt.imgURL.apply(rt,arguments)
},imgSize=function(){
returnrt.imgSize.apply(rt,arguments)
},avatar=function(){
returnrt.avatar.apply(rt,arguments)
},isVerified=function(){
returnrt.isVerified.apply(rt,arguments)
},url=function(){
returnrt.url.apply(rt,arguments)
},mkurl=function(){
returnrt.mkurl.apply(rt,arguments)
},GACampaignURL=function(){
returnrt.GACampaignURL.apply(rt,arguments)
},escape=function(){
returnrt.escape.apply(rt,arguments)
},__t=rt.templates,
emerge=function(){
returnrt.renderSync.apply(rt,arguments)
};
__t["base/people_pins"]=function(locals){
varbuf=[];
with(locals||{}){
varinterp,__val__=emerge("base/header");
buf.push(null==__val__?"":__val__);
var__val__=emerge("base/people_layout",{
req:req,
user:page.user,
ctx:"pins",
body_tpl:"base/people_pins_body",
page:page
});
buf.push(null==__val__?"":__val__)
}
returnbuf.join("")
},__t["base/chrome_callout"]=function(locals){
varbuf=[];
with(locals||{}){
varinterp;
buf.push("
<
div"),buf.push(attrs({
id:"chrome_callout",
style:"display:none;",
"class":"has-closephide"
})),buf.push(">
"class":"wrapper"
})),buf.push(">"class":"introsheet"
})),buf.push(">安装花瓣的chrome采集工具,你可以方便地收集网络上的图片,视频及网页截图,这是花瓣的精髓所在。target:"_blank",
href:"#",
onclick:"returnfalse;",
"class":"install-extensionbtnbtn18rbtn"
})),buf.push(">安装花瓣Chrome扩展"class":"close"
})),buf.push('>
')
}
returnbuf.join("")
},__t["base/header_main_menu"]=function(locals){
varbuf=[];
with(locals||{}){
varinterp,categories=settings.categories,
groups=[];
for(vari=0,l=categories.length;ivarcategory=categories[i];
if(category.display===!1)continue;
category.nav_link="/favorite/"+category.id+"/",groups[category.group]=groups[category.group]||[],groups[category.group].push(category)
}
buf.push("id:"header_main_menu"
})),buf.push(">"class":"innerclearfix"
})),buf.push(">"class":"left-module"
})),buf.push(">href:"/following/",
"class":"main-linkboldfollowing"
})),buf.push(">我的关注href:"/all/",
"class":"main-linkboldallwith-line"
})),buf.push(">最新采集href:"/design/?md=top",
"class":"main-linkdesign"
})),buf.push(">花瓣设计href:"/ent/?md=top",
"class":"main-linkent"
})),buf.push(">花瓣娱乐"class":"new-icon"
})),buf.push(">href:"/gift/?md=top",
"class":"main-linkgift"
})),buf.push(">花瓣礼物href:"/weekly/",
"class":"main-linkweekly"
})),buf.push(">周刊target:"_blank",
href:"http://visionblog.huaban.com/",
"class":"main-linkvisionblogwith-line"
})),buf.push(">访谈target:"_blank",
href:"/apps/",
"class":"main-linkapps"
})),buf.push(">移动应用
"class":"right-module"
})),buf.push(">"class":"row-0"
})),buf.push(">"class":"group"
})),buf.push(">");
for(var$index=0,$$l=groups[0].length;$index<$$l;$index++){
varcat=groups[0][$index];
buf.push("href:cat.nav_link
})),buf.push(">"+escape((interp=cat.name)==null?"":interp)+"")
}
buf.push("
"class":"row-1"
})),buf.push(">"class":"group"
})),buf.push(">");
for(var$index=0,$$l=groups[1].length;$index<$$l;$index++){
varcat=groups[1][$index];
buf.push("href:cat.nav_link
})),buf.push(">"+escape((interp=cat.name)==null?"":interp)+"")
}
buf.push(""class":"group"
})),buf.push(">");
for(var$index=0,$$l=groups[2].length;$index<$$l;$index++){
varcat=groups[2][$index];
buf.push("href:cat.nav_link
})),buf.push(">"+escape((interp=cat.name)==null?"":interp)+"")
}
buf.push(""class":"row-2"
})),buf.push(">"class":"group"
})),buf.push(">");
for(var$index=0,$$l=groups[3].length;$index<$$l;$index++){
varcat=groups[3][$index];
buf.push("href:cat.nav_link
})),buf.push(">"+escape((interp=cat.name)==null?"":interp)+"")
}
buf.push(""class":"group"
})),buf.push(">href:"/all/videos/"
})),buf.push(">视频");
for(var$index=0,$$l=groups[4].length;$index<$$l;$index++){
varcat=groups[4][$index];
buf.push("href:cat.nav_link
})),buf.push(">"+escape((interp=cat.name)==null?"":interp)+"")
}
buf.push("");
if(req.promotions&&req.promotions.dropdown_icontxt_promotions&&req.promotions.dropdown_icontxt_promotions.length){
buf.push(""class":"grouppromotion"
})),buf.push(">");
for(vari=0,$$l=req.promotions.dropdown_icontxt_promotions.length;i<$$l;i++){
varpromo=req.promotions.dropdown_icontxt_promotions[i];
i<=6&&(buf.push("href:""+promo.promotion_url+"",
target:promo.open_in_new_tab?"_blank":"_self",
"class":"brown-link"
})),buf.push(">"+escape((interp=promo.title)==null?"":interp)+""))
}
buf.push("")
}
buf.push(""class":"bottom-bar"
})),buf.push(">onclick:"app.switchHeaderTo('side');returnfalse;",
href:"#",
"class":"to-sidebtn-with-iconbtn"
})),buf.push(">"class":"pin-icon"
})),buf.push(">"class":"text"
})),buf.push(">固定到左侧"class":"links"
})),buf.push(">href:"/about/#goodies"
})),buf.push(">花瓣采集工具href:"/about/"
})),buf.push(">关于我们href:"/fm/joinus/"
})),buf.push(">加入我们href:"/pins/53553/"
})),buf.push(">用户反馈href:"/about/#links"
})),buf.push(">友情链接"class":"up-arrow"
})),buf.push('>
')
}
returnbuf.join("")
},__t["base/people_likes_boards"]=function(locals){
varbuf=[];
with(locals||{}){
varinterp,__val__=emerge("base/header");
buf.push(null==__val__?"":__val__);
var__val__=emerge("base/people_layout",{
req:req,
user:page.user,
ctx:"likes",
body_tpl:"base/people_likes_boards_body",
page:page
});
buf.push(null==__val__?"":__val__)
}
returnbuf.join("")
}
........
})(app);

			
回首忆惘然
浏览 291回答 2
2回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript