/ Published in: JavaScript
URL: http://mir.aculo.us/2011/03/09/little-helpers-a-tweet-sized-javascript-templating-engine/
Using: t("Hello {who}!", { who: "JavaScript" }); t("Hello {who}! It's {time} ms since epoch.", { who: "JavaScript", time: Date.now });
Expand |
Embed | Plain Text
function t(s,d){ for(var p in d) s=s.replace(new RegExp('{'+p+'}','g'), d[p]); return s; }
You need to login to post a comment.
