2011-06-23 15 views
0

我想使用Rails的清單方法3.1如何同時使用@charset指令,並體現在SCSS文件的Rails 3.1

/* 
    *= require_self 
    *= require_tree . 
    */ 

不過,我還需要指定的編碼指令

@charset "UTF-8"; 

這些似乎都需要在第一行解釋,但只有一個可以。所以要麼我得到我的字符集指令或我得到Sprockets清單。

我該如何得到兩者?

回答

1

只需將任何需要的CSS /上海社會科學院文件@charset "UTF-8";不使用要求指令鏈輪,它會被正確編譯到application.css的頂部(見Handle @charset in CSS concatenations

UPD:另一種方法是在添加了@charset "UTF-8";之後的Sprockets評論。無論如何,鏈輪將它切出並插入頁面的頂部。

+0

謝謝,儘管這並不完全是我所需要的答案 - 我想在包含Sprockets require指令的同一個文件中使用它。問題是如何讓BOTH進入文件。 – Jason

+0

@jason,看到更新的答案。 –

0

UPD:另一種方法是添加@charset「UTF-8」;在鏈輪評論之後。無論如何,鏈輪將它切出並插入頁面的頂部。

這對我的工作很好,只是要確保你還包括require_self也 - 之前,我開始,我application.css不包括這一點,所以它不是拿起我的@charset =「 UTF8" ;

最終的結果結束了尋找這樣的 - 只是萬一別人撞了他們的頭靠在這個牆上:

/* 
* This is a manifest file that'll automatically include all the stylesheets available in this directory 
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at 
* the top of the compiled file, but it's generally better to create a new file per style scope. 
*= require_self 
*= require <your other requires go here> 
*/ 
@charset "utf-8"; 
相關問題