Skip to content

Instantly share code, notes, and snippets.

@kanakiyajay
Created June 7, 2015 18:08
Show Gist options
  • Save kanakiyajay/d65cf59f2cc64ba07d89 to your computer and use it in GitHub Desktop.
Save kanakiyajay/d65cf59f2cc64ba07d89 to your computer and use it in GitHub Desktop.
Quick Templating Engine for javascript
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