Last active
March 27, 2019 08:36
-
-
Save imikay/a0487aecbde27a3d4b12 to your computer and use it in GitHub Desktop.
Simple js template engine
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
function render(template, vars) | |
{ | |
for (var v in vars) | |
{ | |
var pattern = '{{' + v + '}}'; | |
template = template.replace(new RegExp(pattern, 'gi'), vars[v]); | |
} | |
return template; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment