Skip to content

Instantly share code, notes, and snippets.

View prograk's full-sized avatar
💭
Nothing

Akshay Malhotra prograk

💭
Nothing
  • Banglore
  • 03:47 (UTC +05:30)
View GitHub Profile
@jlis
jlis / gist:5669677
Created May 29, 2013 11:40
Javascript format function to replace placeholders in a string with content
// usage:
// string.format({key: replacement})
//
// example:
// 'Hello {name}, how are you doing? I am doing {mood}.'.format({name: 'Mike', mood: 'fine'});
String.prototype.format = function() {
var formatted = this;
if (arguments.length && typeof arguments[0] == 'object') {
var vars = arguments[0];
for (v in vars) {