Skip to content

Instantly share code, notes, and snippets.

@pedromcunha
Created July 21, 2014 20:24
Show Gist options
  • Select an option

  • Save pedromcunha/4c1024f02ee4c0c31de3 to your computer and use it in GitHub Desktop.

Select an option

Save pedromcunha/4c1024f02ee4c0c31de3 to your computer and use it in GitHub Desktop.
Formatting CartoCSS function
String.prototype.format = (function (i, safe, arg) {
function format() {
var str = this,
len = arguments.length + 1;
for (i = 0; i < len; arg = arguments[i++]) {
safe = typeof arg === 'object' ? JSON.stringify(arg) : arg;
str = str.replace(RegExp('\\{' + (i - 1) + '\\}', 'g'), safe);
}
return str;
}
//format.native = String.prototype.format;
return format;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment