Je m’appelle Cédric Bozzi, je crée des sites et des applications, et ceci est mon blog dédié à la technologie : vous y trouverez des news, des opinions et des tests, le tout écrit par un Mac-head aux opinions tranchées.
This. Is. Magical.
If you don’t know what Less is (I didn’t — or I must have heard about it once and promptly forgotten), it’s a Ruby application descended from Heaven to let you write parametric CSS files.
You can set up variables (e.g., color values) in the beginning of your file, reference them everywhere and only have to change the value once when you want to update the look of your entire site. You can do some math on those values (e.g., dimmer or brighter variations of those colors for some elements). You can create helper classes to include into the definition of other classes (e.g., cross-browser shadows or rounded corners), and they can even behave like functions (e.g., take the corner radius as a parameter). More info on lesscss.org.
It becomes annoying, though, in that every time you edit your CSS you have to run the file through a compiler — you can’t just upload the parametric CSS as is, you have to turn it into a regular .css file (at least as far as I know; maybe there is, or will be someday, an Apache plugin or whatever). Nobody wants to have to bother with that, and that’s where this excellent new app comes in: just give it a list of folders containing your .less files, and it will watch them and compile them into .css files every time they’re updated. There you go, .css files ready to be uploaded. (For now, the Less app doesn’t automatically send the compiled files to your FTP program, but the developer assures me that’s coming.)
If you’ve ever maintained somewhat complex CSS files, you know you want this.
A hint: if you want to install the Less compiler on Leopard (the application doesn’t install it by itself, for some reason), you’re going to need one more command-line instruction than documented on lesscss.org.
sudo gem update −−system
sudo gem install less
Also, the compiler can be a little picky about the CSS it wants to compile. For instance, having a comma-separated list of CSS selectors, with some of them commented out, will throw a syntax error. Just work around it.