Skip to content

Instantly share code, notes, and snippets.

@danigb
Created April 24, 2019 13:38
Show Gist options
  • Save danigb/506439c2952f61070c2df88cbbe872cc to your computer and use it in GitHub Desktop.
Save danigb/506439c2952f61070c2df88cbbe872cc to your computer and use it in GitHub Desktop.
var PATTERN = new RegExp("{([a-z]+)}", "gi");
function tmpl(template, data) {
return template.replace(PATTERN, function(tag, token) {
return data[token];
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment