From: khaines@... Date: 2007-02-07T04:36:02+09:00 Subject: Re: ruby CSS parser On Tue, 6 Feb 2007, _Kevin wrote: > Anyone know of a decent ruby CSS parser? This is the opposite of what you are looking for, but with the upcoming IOWA 1.0 release I have a Ruby CSS DSL -- write CSS with Ruby using a syntax that's about as close as I could get it to actual CSS. It supports everything Ruby does, so variables work as does nesting of selectors into other selectors, and storing a selector into a variable that can be refered to later. It also provides a smart caching feature so that if, for instance, one customizes the generated CSS according to a cookie setting, it can cache that generated CSS and reuse it without having to execute all of the DSL code for every request. The goals are to provide much DRYer CSS using Ruby that looks a lot like CSS, with easy support for dynamic CSS generation, all covered under the syntax checking of the Ruby parser (which should help one catch simple errors). And because it's all Ruby code, it's easy to write tests to validate dynamically generated CSS. Here's a quick preview: Media.screen { body { font { color 'green' size 12.px } } } If one wants to refer to something later, one may: Media.screen { body { base_font = font { color :green size 12.px } footer { font { size base_font - 2 color :black } } } } All CSS1, CSS2, and CSS3 selectors are supported. Kirk Haines