CSS with ERB 2

Posted by Colin A. Bartlett Sat, 21 Jul 2007 21:17:00 GMT

As I started to get deeper into creating the stylesheet for our latest project, I got annoyed with having to repeat the same color hex codes all over the place. There are many solutions to this dilemma but I liked this one the best. (Note the blog name is a coincidence.)

I had to modify the suggested route slightly as this article is fairly outdated and doesn’t work with the latest rails version that considers dot a separator in routes. So I used this:

map.connect 'stylesheets/:rcss.:format', :controller => 'stylesheets', :action => 'rcss'

So far this is working great. I have several color codes setup as instance variables in the controller. Andy suggested I try moving this to perhaps a layout for the css. If the list of variables gets unwieldy I’ll do just that.

Speaking of color hex codes, this car license plate is pretty funny.

Trackbacks

Use the following link to trackback from your own site:
http://blog.kineticweb.com/articles/trackback/47

Comments

Leave a response

  1. Avatar
    Mat Schaffer 3 days later:
    Don't forget SASS :)

    http://haml.hamptoncatlin.com/docs/sass

    I've been using haml a fair bit recently and love it so far. Haven't gotten into SASS yet, but it would solve your variable problem and introduce nested awesomeness.
  2. Avatar
    Colin 5 days later:
    I'll definitely try out this SASS! I started converting all my templates on an internal project to HAML a few months back. But it got sidelined. I really liked it though. Very clean and elegant.
Comments