2010-11-14 33 views
1

Rails相當新穎。我正在Rails站點上實施批發主頁重新設計。目前,我們將推動重新設計的主頁,但將網站的其餘部分保留原樣。稍後,我們將把網站的其餘部分移植到新設計中。讓SASS從多個目錄生成CSS文件

我想在當前僅由主頁加載的項目中創建CSS的「分支」。我們使用SASS生成CSS。文件格式:

/public/stylesheets:   #Generated CSS for rest of site 
/public/stylesheets/sass: #SASS source files for rest of site 
/public/stylesheets/v3:  #Desired location for CSS for home page 
/public/stylesheets/v3/sass: #SASS source files for new-style home page 

/電話render :layout => 'v3',而這種佈局控制器包含:

!= include_stylesheets :common_v3, :media => "all" 

下面是從assets.yml相關部分:

stylesheets: 
    common: 
    - public/stylesheets/reset.css 
    - public/stylesheets/*.css 

    common_v3: 
    - public/stylesheets/v3/reset.css 
    - public/stylesheets/v3/*.css 

有人能幫助我弄清楚如何讓SASS生成新的CSS文件?如果我在/public/stylesheets/sass中放置了一個新文件,則會創建相應的CSS文件,但v3目錄會被忽略。

我在environment.rb中嘗試了以下內容,但它不工作。

Sass::Plugin.options[:template_location] = %W(#{RAILS_ROOT}/public/stylesheets/sass #{RAILS_ROOT}/public/stylesheets/v3/sass) 

使用Rails 2.3.8和Haml 2.2.2。

回答

2

首先,將Haml/Sass升級到最新版本(3.0.24)。

現在您可以使用Sass::Plugin.add_template_location method來告訴Sass您的模板在哪裏。例如:

Sass::Plugin.add_template_location("#{RAILS_ROOT}/public/stylesheets/v3/sass", 
            "#{RAILS_ROOT}/public/stylesheets/v3") 
相關問題