RubyCSS

Hello List!

I’ve been hacking at an interesting experiment using mxied in class
functions to build and generate css.

The result is RubyCSS, which takes something like the following and
turns it
into compact CSS.

require ‘rubycss’

class Test
include RubyCSS::StyleSheet

abstract :text_base do
color c(:red)
end

select “.test” do
extends :text_base
margin 12
end
end

puts Test.compile
=> .test {color: #ff0000; margin: 12px;}

If you feel like taking it for a spin, it can be found at

My goal is to stick to vanilla Ruby, and I’ve found it very a nice match
for
complex style sheets.

Some of my goals involve:

  • Better color arithmetics
  • Add more aliased and expanding css rule (like border-radius =>
    -moz-border-radius, -webkit-border-radius and border-radius)
  • Define sensible default stylesheet rules, like sets of fonts or grid
    layouts.
  • Better and configurable implicit conversions (like 12 → “12px”).

I hope you find it useful!

– John-John T.

On Aug 12, 3:29pm, John-John T. [email protected] wrote:

class Test
include RubyCSS::StyleSheet

Any reason you did not make this a base class rather than a mixin?
Seems like a base class would be a better fit.

I hope you find it useful!

Could be very.

On Sat, Aug 13, 2011 at 4:45 AM, Intransition [email protected]
wrote:

into compact CSS.

Could be very.

I was messing around with a base class initially, but then I also wanted
to
be able to mix in some functionality into modules and wanted both cases
to
use similar methods.

But you are right, using a base class would be a bit more straight
forward
implementation wise for this case.