Skip to content

Instantly share code, notes, and snippets.

@bebraw
Created March 29, 2013 16:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bebraw/5271769 to your computer and use it in GitHub Desktop.
Save bebraw/5271769 to your computer and use it in GitHub Desktop.
var ctx = {
name: 'jude'
};
var tpl = "hey {{ name }}, don't make it bad";
var res = tpl.replace(/\{\{([a-zA-Z ]*)\}\}/g, function(m, g) {
return ctx[g.trim()];
});
console.log(res);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment