Re: Good solution for managing stylesheets

Jeffrey Moss
Fri, 19 Aug 2005 21:50:10 -0000

Ah so the partials are rendered first then. That is good to know.

-Jeff

----- Original Message -----
From: "Jamis Buck"
<jamis-uHoyYlH2B+GakBO8gow8eQ@public.gmane.org>
To: <rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org>
Sent: Friday, August 19, 2005 3:36 PM
Subject: Re: [Rails] Good solution for managing stylesheets


> On Aug 19, 2005, at 3:31 PM, Jeffrey Moss wrote:
>
>> Does anybody figure they have the perfect solution for managing
>> stylesheets when using layouts and partials?
>>
>> I''d like a way for each partial to automatically include
something
>> in the header section of the layout, when it is used. Right now I
>> just have the layout setup to include 3 stylesheets, one called
>> "default", another called the controller name, and another
called
>> the action name, but this of course has limitations.
>>
>> I thought there was something in the works to handle this (having
>> things appear in the header that were called in a template or
>> partial), was that idea scrapped? I imagine it presents a few
>> problems, I mean it''s sortof dirty to automatically include
>> stylesheets based on what the page is composed of, I may need to
>> just switch to a controller-based add_stylesheet macro or something...
>>
>
> I''ve done the following in the past. Anytime I have another
> stylesheet I want used (in a partial, for instance), I just do:
>
>   <% (@stylesheets ||= []) << "my_stylesheet" %>
>
> And then in the master layout:
>
>   <% stylesheet_link_tag(*@stylesheets) if @stylesheets %>
>
> It''s simple, easy to extend, and doesn''t require any
special
> infrastructure.
>
> - Jamis
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails