Created
August 22, 2013 05:40
-
-
Save bmount/6303548 to your computer and use it in GitHub Desktop.
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
| function urlTmpl (tmpl, obj) { | |
| return tmpl.replace(/{{([a-zA-Z0-9]+)}}/g, function (s, v) { return obj[v] }) | |
| } | |
| /* | |
| > urlTmpl('shit is {{status}} and {{qualifier}}', { status: 'fucked up', qualifier: 'bullshit' }) | |
| "shit is fucked up and bullshit" | |
| > urlTmpl('shit is {{status}} and {{qualifier}}', { status: 'fucked up', oops_qualifier: 'bullshit' }) | |
| "shit is fucked up and undefined" | |
| */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment