Created
March 29, 2013 12:09
-
-
Save nessthehero/5270457 to your computer and use it in GitHub Desktop.
Micro-Templating
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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