Skip to content

Instantly share code, notes, and snippets.

@jimmybatuhan
Created July 31, 2019 07:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jimmybatuhan/206fa33d24ecd7a257c35644885d4ff2 to your computer and use it in GitHub Desktop.
Save jimmybatuhan/206fa33d24ecd7a257c35644885d4ff2 to your computer and use it in GitHub Desktop.
HandleBar
let handlebar = function(string, handlers){
if(string.match(/({{).*?(}})/g).length){
Object.keys(handlers).forEach( key => { string = string.replace(new RegExp("({{)"+key+"(}})"), handlers[key]); });
};
return string;
};
module.exports = handlebar();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment