.css.erb files ?

hi, with Rails 2.0, we have view templates with the new .html.erb extensions, but can also have .css.erb files.

does this mean i can put my css files inside my view templates like screen.css.erb or have i got the wrong end of the stick,

appreciate anyones answer on this,

stylesheet files should live in public/stylesheets and should be linked to by using <%= stylesheet_link_tag “name” %> in the layout of your site, inside a tag.

i haven't used it yet, but i think that it's more about using erb code within your css file, which would allow to give them some nice things like user selectable color sets

.menu {   color: <%= @user.settings.text_color; %>   background: <%= @user.settings.bg_color; %>; }

hmm, i can think about a lot of stuff to do with it if it works that way.

yep, Thorsten, would be pretty cool to have dynamic css files, don't think it works this way just confused by the extension.

maybe it's similar to haml?

Maybe you could store the user's color selections in a sort of "user preferences" model (which is what I've done with other user info).

I track the user's preferred "page length" (rows per page in an index view), "sort order" per model (saves their current sort columns and order when they logout so its the same when they come back).

I was just thinking about colors the other day - one co-worker doesn't see certain blue hues - "What highlight?" he asks...

Perhaps a "standard" stylesheet with my colors, then a stylesheet M-V-C that can maintain a css file per user, and some simple file selection logic in the main layout. Hmm...

Oh, and kuler.adobe.com is a great source for manufacturing/finding color schemes...

You can dynamically link a css file (contra Radar ^^^) by using yield and content_for

In the layout:

<head> ... <%= yield :head %> </head>

In the *.html.erb <% content_for :head do %> <% stylesheet_link_tag :page_specific_styles <% end %>

Of course, if you _needed_ page specific, dynamic css you could put a style tag inside your content_for :head.

John Griffiths wrote:

yep, Thorsten, would be pretty cool to have dynamic css files, don't think it works this way just confused by the extension.

maybe it's similar to haml?

You just have to think about how we normally find stylesheets, namely we link to a file located at "/stylesheets/blah.css"

normally this looks for a static file in "/public/stylesheets/blah.css"

but try adding a controller called Stylesheets.

now rails routing will look for a method called "blah" on the StylesheetsController.

try it, tweak it, cache it... boom

proper dynamic css.

thanks, i'll have a bash and see how it goes.

appreciate this,

John.