Created
June 7, 2015 18:08
-
-
Save kanakiyajay/d65cf59f2cc64ba07d89 to your computer and use it in GitHub Desktop.
Quick Templating Engine for javascript
This file contains 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 template(s,d){ | |
for(var p in d) | |
s=s.replace(new RegExp('{'+p+'}','g'), d[p]); | |
return s; | |
} | |
template('Hello {name}', {name: 'Jay'}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment