Skip to content

Instantly share code, notes, and snippets.

@nessthehero
Created March 29, 2013 12:09
Show Gist options
  • Save nessthehero/5270457 to your computer and use it in GitHub Desktop.
Save nessthehero/5270457 to your computer and use it in GitHub Desktop.
Micro-Templating
// Tweet sized templating (the JSLinted version)
// http://mir.aculo.us/2011/03/09/little-helpers-a-tweet-sized-javascript-templating-engine/
function t(s, d) {
var p;
for (p in d) {
if (d.hasOwnProperty(p)) {
s = s.replace(new RegExp('{' + p + '}', 'g'), d[p]);
}
}
return s;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment