Created
December 11, 2011 18:08
-
-
Save niyazpk/1461856 to your computer and use it in GitHub Desktop.
This file contains 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
// Templates: | |
param = { media: 'http://media.valvion.com/' }; | |
url = "{media}logo.gif".supplant(param); | |
// Unfortunately, supplant method is not there in ES5 spec, | |
// so use the below prototype: | |
if (!String.prototype.supplant) { | |
String.prototype.supplant = function (o) { | |
return this.replace(/{([^{}]*)}/g, | |
function (a, b) { | |
var r = o[b]; | |
return typeof r === 'string' || | |
typeof r === 'number' ? r : a; | |
} | |
); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment