From: khaines@... Date: 2007-03-23T03:21:33+09:00 Subject: Re: eRuby and CSS On Fri, 23 Mar 2007, John Joyce wrote: > I basically want to have a CSS preprocessor, server-side of course. (I'd > actually like CSS3 to be finished and widespread, but that's like watching > rocks grow) > This looks interesting. Perhaps. > It's on the right track with variables to substitute in for commonly used > values. That's one of the big things lacking in CSS now. But it doesn't seem > as simple as it should/could be. > > But perhaps the best approach is building my own ERb solution and using > something with Rails API AssetTagHelper from rails/actionpack/ > action_view/helpers/asset_tag_helper.rb > stylesheet_link_tag(*source) > piped through ERb? > Need to sit down with it later! I have a DSL for CSS that makes variable substitution and so much more really easy, by writing ruby code that, for the most part, looks a lot like the CSS that is generated by it. font_color = '#001382' border_style = '3 px ridge #a0e0b0' Media.screen { body { font { size 15.px color font_color family :verdana } background_color '#ececff' Id.header { border border_style padding 1.em } } It supports the full range of CSS1..3 selectors as well as intelligent caching of the generated CSS -- given conditional logic such as a check to see if the browser is an IE version prior to IE7, one can have it generate different CSS, and those different versions of the generated CSS will be cached. This is written for use with the IOWA web framework, but I could be convinced to release this as a standalone microproject that also included support as a rails plugin or whatever might be necessary for other frameworks. Kirk Haines