SASS全局变量+ Rails 3.1

| 我正在使用带有默认SASS设置的Rails 3.1RC4。我有以下文件 application.css.scss
/*
 * 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_tree . 
*/
_variables.css.scss
$var1 : somevalue;
...
site_layout.css.scss
@import \"variables\";
... Some Sass Code
但是我无法访问site_layout中_variables.css.scss中定义的变量。我究竟做错了什么? Rails显然是在查找变量文件,因为它不会引发“找不到文件”错误,如果我更改导入文件名,它也会这样做。 var仍然没有结转。 有任何想法吗? 谢谢!     
已邀请:
        该问题似乎已通过最新版本的rails和sp链轮解决。在您的gemfile中:
gem \'rails\', :git => \"git://github.com/rails/rails.git\", :branch => \"3-1-stable\"
    
        问题的第一部分((4ѭ代码段)在这里似乎没有任何意义,因为它只是注释掉的代码,因此我将跳过该部分。 对于第二个代码段,我不相信SASS会像您在此处所做的那样设置为导入“部分”。您最好做这样的事情: _variables.scss(从_variables.css.scss重命名):
$var1: somevalue;
请注意,文件名中的下划线不是必需的,就像Ruby部分一样。只要将import语句更改为ѭ7,就可以轻松将其命名为
variables.scss
。 site_layout.scss(从site_layout.css.scss重命名)
@import \"_variables\";

.test_thingy {
  color: $var1;
  }
这将生成一个“ 9”文件,其中包含以下代码替换:
.test_thingy {
  color: somevalue; }
请注意,与使用HAML / ERB文件一样,不需要像ѭ11这样的文件。只需将文件命名为您想要的名称即可。例如,“ 12”将使SASS自动生成一个名为“ 13”的CSS文件。     

要回复问题请先登录注册