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(); |
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 name = 'James Bond'; | |
let names = [ | |
'Goerge Mallory', | |
'Marie Curry', | |
'Tom Yorke', | |
'Jimmy Wales', | |
'James Blonde', | |
'j@M3$ b0ND', | |
]; |