Last active
August 4, 2017 08:53
-
-
Save nerik/9a31d02077c8fd1ed444f7d15f916a87 to your computer and use it in GitHub Desktop.
This file contains 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
// ES6 allows multiline strings with backticks, and it is natively available on all browsers except IE | |
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals | |
// just changing the docs to promote using ES6 by default (with an ES5 fallback) would already help a great deal | |
var countriesStyle = new carto.style.CartoCSS(` | |
#layer { | |
polygon-fill: #333333; | |
} | |
`); |
This file contains 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
// baked in simple object literal to multiline string conversion shouldn't be to hard to implement | |
var countriesStyle = new carto.style.CartoCSS({ | |
'#layer': { | |
'polygon-fill': '#333333' | |
} | |
}); | |
// and this would also allows for interesting scenarios with dynamically generated CartoCSS | |
// (again using an ES6 feature, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer) | |
var layerName = '#layer'; | |
var num = 42; | |
var countriesStyle = new carto.style.CartoCSS({ | |
[layerName]: { | |
'polygon-fill': '#333333' | |
} | |
[`someLayer${num}`]: { | |
'polygon-fill': '#333333' | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment