Created
April 20, 2018 09:55
-
-
Save pietrom/ca19874c1377a5be8d9363ced210b35e to your computer and use it in GitHub Desktop.
Replace placeholders in string template
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 process(tpl, params) { | |
| return Object.keys(params).reduce(function(acc, curr) { return acc.replace("[" + curr + "]", params[curr]);}, tpl) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment