Last active
October 11, 2015 19:18
-
-
Save tored/3907264 to your computer and use it in GitHub Desktop.
supplant
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
function supplant(s, o) { | |
return s.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