Created
July 21, 2014 20:24
-
-
Save pedromcunha/4c1024f02ee4c0c31de3 to your computer and use it in GitHub Desktop.
Formatting CartoCSS function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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