4 ms·
I don't see how using selectors like: '#id .className': do -> is preferable to: #id .className { Also, the fact that this looks like CoffeeScript co
by cobychapple 14y ago
I don't see how using selectors like:
'#id .className': do ->
is preferable to:
#id .className {
Also, the fact that this looks like CoffeeScript could really confuse people who see this code in a project and assume it compiles to JS.
IMHO If you're after more from your CSS, just use Sass (or LESS if you don't want the Ruby dependancy).
- pyrotechnick 14y agoThe quotes around the selector are necessary in CoffeeScript since it does not comprehend the syntax of CSS (# denotes comments). The `do ->` is a self-invoking function which allows for logic and computation in style definitions. These are particularly concise in CoffeeScript since functions implicitly return the result of their final expression.
- Cushman 14y agoIt doesn't look like CoffeeScript, it is CoffeeScript, and it does compile to JavaScript. `: do ->` is idiomatic CoffeeScript to set a complex value inside an object literal; it compiles to `: (function () {...})()`. The output of that file is a JavaScript object which is translated into CSS by the library. This might be preferable to raw CSS or LESS/Sass if you want to write more complex CSS generation code in the same language as the rest of your stack, especially if you want to integrate your CSS with the rest of your app somehow. I'm a big fan of the idea in the abstract, although I'm not sure I love this implementation.