Rails 4:如何使用Sass映射? [英] Rails 4: how do I use Sass Mappings?

查看:104
本文介绍了Rails 4:如何使用Sass映射?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图清理一些Rails 4.1应用程序的样式。

 

code>#colors.css.scss
$ colors:(
red:#330000,
blue:#003300
);但是,我收到以下错误:









$ b b

 $ colors:(red:expected)之后的CSS无效,为:#330000,blue ...

我可以使用Sass变量和mixins很好;为什么我不能使用SASS映射?

解决方案

正如@dinocarl指出, SASS的映射列表的功能均为版本3+。我不得不升级 sass-rails gem到版本5+,因为那个版本的gem包SASS 3+。在我升级gem版本后,像一个魅力(也有几个额外的依赖,我不得不更新)。


I'm trying to cleanup some of my styles for a Rails 4.1 app. Instead of listing out every color and it's variations, I would like to create a mapping of colors/values and then generate the CSS by iterating over it.

# colors.css.scss
$colors: (
  "red": #330000,
  "blue": #003300
);

However, I get the following error from this:

Invalid CSS after "$colors: (red": expected ")", was ": #330000, blue..."

I can use Sass variables and mixins just fine; why can't I use SASS mappings as well?

解决方案

As @dinocarl kindly pointed out, the map and list features of SASS are in version 3+. I had to upgrade sass-rails gem to version 5+ because that version of the gem packages SASS 3+. Worked like a charm after I upgraded the gem version (also were few additional dependencies I had to update).

这篇关于Rails 4:如何使用Sass映射?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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