通过Assets Pipeline,Rails 3.1 rc1携带Sass变量 [英] Carry Sass variables through the Assets Pipeline, Rails 3.1 rc1

查看:72
本文介绍了通过Assets Pipeline,Rails 3.1 rc1携带Sass变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近用3.1 rc1分支了我的Rails 3.0项目之一,以尝试新的资产管道.在进入3.1之前,我一直在项目中使用Sass,所以我一直在一个单独的配置文件中设置一些变量和函数,然后让我所有其他sass文件在第一行导入该文件.

I recently branched one of my Rails 3.0 projects with the 3.1 rc1 to try the new assets pipeline. I've been using Sass in the project before going 3.1 so I've been setting up some variables and functions in a separate configure file and let all my other sass files import that one file at the first line.

在样式表中不重复一些颜色代码和常规几何图形的做法非常有用.现在,新的Assets Pipeline出现了问题,据我所知,它将".css.sass"文件转换为原始CSS,然后再将其附加到其余代码中.

This has been working out great to not repeat some color codes and general geometry through in the stylesheets. Problem is now with the new Assets Pipeline is that as I've understood it converts the ".css.sass" files to raw css before appending it to the rest of the code.

因此,如果我在"application.css"中指定:

So if i specify, in my "application.css":

/*
 *= require ./configure
 *= require ./what_ever_other_files_i_want_to_import
*/

我收到如下错误:

Sass::SyntaxError
    Undefined variable: "$interactive".

当我尝试从以下位置访问文件时:http://localhost:3000/assets/application.css

When i try to access the file from: http://localhost:3000/assets/application.css

有什么想法吗?

推荐答案

Sass支持

Sass supports Partials. That way you can include your separate configuration in __configuration.sass_ and reference it with

@import "configuration";

从您的主要sass文件中获取.

from your main sass-file.

这篇关于通过Assets Pipeline,Rails 3.1 rc1携带Sass变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆