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

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

问题描述

我正在尝试清理 Rails 4.1 应用程序的一些样式.我不想列出每种颜色及其变体,而是想创建颜色/值的映射,然后通过迭代生成 CSS.

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..."

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

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

推荐答案

正如@dinocarl 所指出的,SASS 的 maplist 功能在 3+ 版本中.我不得不将 sass-rails gem 升级到版本 5+,因为那个版本的 gem 包 SASS 3+.在我升级 gem 版本后,它的工作就像一个魅力(我还必须更新一些额外的依赖项).

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天全站免登陆