Created
July 31, 2019 07:50
-
-
Save jimmybatuhan/206fa33d24ecd7a257c35644885d4ff2 to your computer and use it in GitHub Desktop.
HandleBar
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
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