Re:T.js - A tiny templating framework in ~400 bytes
by alexgartrell on Monday August 13, 2012 @07:41PM
(#4378710)
Seems Legit
[ Parent
| on HN ]
Re:T.js - A tiny templating framework in ~400 bytes
by pfraze on Monday August 13, 2012 @07:53PM
(#4378740)
function render(tpl,data){
var matches = tpl.match(/{[^\}]+}/g);
for(var i in matches){
var rep = eval("data."+matches[i].replace(/[{}]/g,''));
tpl = tpl.replace(matches[i],rep);
}
return tpl;
}
Fixed
Re:T.js - A tiny templating framework in ~400 bytes
by vain on Monday August 13, 2012 @07:49PM
(#4378727)
looks like something broke in copying and pasting. try:
http://pastebin.com/txM6NZBS