问题描述
我试图清理一些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
andlist
features of SASS are in version 3+. I had to upgradesass-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映射?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!