-
-
Save spalger/dc4533e0c5b855f3c2e197af4bc541af 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
const get = require('lodash.get') | |
const vars = { first: 'spencer', last: 'alger', age: 28 } | |
return 'Mr. { first } {last }, age {age}'.replace(/\{\s*(.+?)\s*\}/g, (_, name) => get(vars, name)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment