Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Just string templating.
String.prototype.format = function( params, opts){
var opts = opts || new Object();
opts.head = opts.head || '${';
opts.tail = opts.tail || '}';
var r = this;
for(param in params)
r = r.split( new Array(opts.head, param, opts.tail).join('') ).join(params[param]);
return r;
// var template = 'awe${neat}'.format({'neat':'some'});
// console.log(template);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.