Yes, you can add stylesheets dynamically to your page via the following helper 
method:

  def stylesheet(*files)
    content_for(:head) { stylesheet_link_tag(*files)}
  end

Best,
Yannis

On 3 juin 2010, at 15:43, Eumir wrote:

> Hmm maybe I'll try that inline style. i kinda thought about it but
> like you said, if the style wasn't just about the header then we're in
> trouble. Also, was the link deliberate? page titles? we already use
> that unless the link was wrong or there are other tips in the
> screencast besides page titles?
> 
> On Jun 3, 7:54 pm, Yannis Jaquet <[email protected]> wrote:
>> Yes, exactly.  Of course, this could be completely unmaintainable if you 
>> have a large number of users or if the style you need to set is quite 
>> complex.
>> You should also think of simply settings your style inline: #header{:style 
>> => 'background-color: whatever'}.
>> There's also many ways to dynamically link your view to a specific 
>> stylesheet. If you're on rails, you should 
>> checkhttp://railscasts.com/episodes/30-pretty-page-title
>> Yannis
>> 
>> On 3 juin 2010, at 13:43, Eumir wrote:
>> 
>> 
>> 
>>> I don't think so since the url will be based on an uploaded file by a
>>> user. so would you mean to say that we make a sass file that includes
>>> all possible headers then just switch it in the view depending on the
>>> user? Something like
>> 
>>> #header-for-user1
>>> :background url(etc)
>> 
>>> #header-for-user2
>>>  :background url(etc)
>> 
>>> then at the view
>> 
>>> if user1
>>>  #header-for-user1
>>> elseif user2
>>>  #header-for-user2
>> 
>>> something like that?
>> 
>>> On Jun 3, 6:58 pm, Yannis Jaquet <[email protected]> wrote:
>>>> Would'nt be easier to dynamically set the class of this #header and  
>>>> change the background color of this header depending on this class?
>> 
>>>> On 3 juin 2010, at 10:56, Eumir <[email protected]> wrote:
>> 
>>>>> is there a way to access ruby variables in sass or do i have to make a
>>>>> custom function for it?
>> 
>>>>> what im trying to do is to generate a stylesheet for each user so in
>>>>> the controller, i do something like:
>> 
>>>>> def show
>>>>> respond_to do |format|
>>>>>   format.css{render :partial => "styles"}
>>>>> end
>>>>> end
>> 
>>>>> then in the view name _styles.haml i do this:
>> 
>>>>> :sass
>>>>> #header
>>>>>   :background url(user.banner.url)
>> 
>>>>> is this possible at all?
>> 
>>>>> -- You received this message because you are subscribed to the  
>>>>> Google Groups "Haml" group.
>>>>> To post to this group, send email to [email protected].
>>>>> To unsubscribe from this group, send email to 
>>>>> [email protected]
>>>>> .
>>>>> For more options, visit this group 
>>>>> athttp://groups.google.com/group/haml?hl=en
>>>>> .
>> 
>>> --
>>> You received this message because you are subscribed to the Google Groups 
>>> "Haml" group.
>>> To post to this group, send email to [email protected].
>>> To unsubscribe from this group, send email to 
>>> [email protected].
>>> For more options, visit this group 
>>> athttp://groups.google.com/group/haml?hl=en.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Haml" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/haml?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Haml" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/haml?hl=en.

Reply via email to