LESS - Leaner CSS - An approach, apparently using Ruby - Any thoughts/ideas on Possibilities of such for Drupal?

kjv1611 - June 26, 2009 - 13:45

I came across this in another forum, and got to wondering if anyone is working on or might be able to work on such a capability as this:

http://lesscss.org/

Apparently, it's for use in Ruby, only, but I was thinking that Ruby, Python, and PHP were pretty close, and therefore I started wondering if anyone in the Drupal world has looked at such.

I have very little experience, to date, of messing with the PHP in Drupal; and even less experience looking at CSS. I want to take the time to do it, but I have so little time, that I often just have to skip all of that.

Anyway, I'd imagine that many people in the Drupal Community would benefit from something along this line (which perhaps someone HAS done something, but I just didn't see it).

Any thoughts from anyone out there?

mm.

dman - June 26, 2009 - 14:20

Certainly has merit.
I've always wanted constants for my colours in CSS, and:

/* LESS */

.rounded_corners {
  -moz-border-radius: 8px;
  -webkit-border-radius: 8px;
  border-radius: 8px;
}

#header {
  .rounded_corners;
}

#footer {
  .rounded_corners;
}

is also pretty intuative. Not sure about the rest.

In the bigger picture, rather than yet another Syntax, I'd suggest looking at what's coming down the line with CSS n+1 and see if we can run a precompiler on our css to emulate the effects and new features. Drupal ALREADY does CSS aggregation, so inserting a precompiler step there will be easy!

.dan.

wow !

tilu - June 26, 2009 - 18:26

just wow !
wonderful idea !

Compass compass

bangpound - June 26, 2009 - 18:51

Compass compass compass!

http://wiki.github.com/chriseppstein/compass

It relies on Sass, which is a more mature Ruby ... library? application? It's a ruby something. Gem! That's it.

So Compass brings known CSS frameworks into the picture: Blueprint, YUI, 960. Sass is a CSS metalanguage that compiles to CSS like LessCSS does. You can create constants to define reusable color or font definitions. You can do math and concatenation in your styles with Sass:

p
:margin-bottom = (!line_height / !font_size) + "em"

It correctly knows CSS units like px, em, %, etc.

but the best thing about Compass is that it makes Sass easier to use outside Ruby projects. I can't recommend compass enough!

 
 

Drupal is a registered trademark of Dries Buytaert.