Skip to content

Instantly share code, notes, and snippets.

@sokil
Last active January 3, 2016 04:39
Show Gist options
  • Save sokil/8410089 to your computer and use it in GitHub Desktop.
Save sokil/8410089 to your computer and use it in GitHub Desktop.
var TemplateEngine = function() {
this.compile = function(template) {
return {
render: function(scope) {
var rendered = template;
for(var key in scope) {
rendered = rendered.replace(new RegExp('\{\{' + key + '\}\}', 'g'), scope[key]);
}
return rendered;
}
};
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment