Skip to content

Instantly share code, notes, and snippets.

@TheBox193
Created August 30, 2016 19:25
Show Gist options
  • Save TheBox193/a0daa634e31c2076a795991525c21f7e to your computer and use it in GitHub Desktop.
Save TheBox193/a0daa634e31c2076a795991525c21f7e to your computer and use it in GitHub Desktop.
A functional style curried LoDash template function, taking in config first, then string, then values. With sample using mustache template.
templateString = _.curry(
(config, string, valueObj) => _.template(string, config )(valueObj)
)
templateMustache = templateString({interpolate: /{{([\s\S]+?)}}/g});
TempString = templateMustache('hello {{user}}!', { user: 'mustache' })
console.log(TempString)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment