Created
June 19, 2015 12:17
-
-
Save AWaselnuk/de138c0c997a24bc8995 to your computer and use it in GitHub Desktop.
Tweet Sized Templating Engine
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
// From: http://mir.aculo.us/2011/03/09/little-helpers-a-tweet-sized-javascript-templating-engine/ | |
function t (s,d) { | |
for (var p in d) | |
s=s.replace(new RegExp('{'+p+'}','g'), d[p]); | |
return s; | |
} | |
// Call it like this: | |
// t("Hello {who}!", { who: "JavaScript" }); | |
// | |
// => "Hello JavaScript!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment