热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

CompassforRails3.1的价值是什么?-WhatisthevalueofCompassforRails3.1?

ImtryingtodecideifIshouldincludeCompasswhenstartinganewRails3.1project.Ihaventus

I'm trying to decide if I should include Compass when starting a new Rails 3.1 project. I haven't used Compass before.

我正在尝试在启动新的Rails 3.1项目时决定是否应该包含Compass。我以前没用过Compass。

Rails 3.1 now supports SCSS directly. The Rails 3.1 asset pipeline (via sprockets) now compiles stylesheets automatically. And I can use a SCSS version of a CSS framework such as Blueprint directly.

Rails 3.1现在直接支持SCSS。 Rails 3.1资产管道(通过链轮)现在自动编译样式表。我可以直接使用蓝图等CSS框架的SCSS版本。

What benefits will I get from using Compass with Rails 3.1?

使用Compass with Rails 3.1可以获得什么好处?

4 个解决方案

#1


14  

Bourbon (by Thoughtbot) is a light alternative to compass that integrates well with rails 3.1.

Bourbon(由Thoughtbot提供)是罗盘的轻型替代品,与轨道3.1完美结合​​。

It has the main css3 mixins you get with compass (background-images, box shadow, border radius, gradients...). It also has helpers to style buttons, "gridify" your layout and a few more goodies.

它有罗盘的主要css3 mixins(背景图像,框阴影,边框半径,渐变......)。它还有样式按钮的助手,“网格化”你的布局和一些更好的东西。

You might miss some of the power features compass has, but that can be easily overcome with the power of sass : just copy/create you're own mixin!

您可能会错过指南针所具有的一些功能特性,但这可以通过sass的强大功能轻松克服:只需复制/创建您自己的混音!

Compass often gave me headaches when upgrading my rails app. I appreciate the simplicty of Bourbon (although it might give you headaches as well... in the morning :-) )

在升级我的rails应用程序时,Compass经常让我头疼。我很欣赏Bourbon的简单(虽然它可能会给你带来头痛......早上:-))

#2


20  

Compass provides a lot of good mixins, a pretty powerful sprite-generator, and a tight integration with Blueprint in a way that means you don't have to use non-semantic col classes all over your HTML.

Compass提供了许多优秀的mixins,一个非常强大的sprite-generator,以及与Blueprint紧密集成的方式,这意味着您不必在HTML上使用非语义col类。

There's not really much benefit to using Compass if you're not using the mixins, but then again there isn't much benefit to using SCSS if you're not using them (nesting and variables are nice, but mixins help keep browser-specific implementation of properties in a single location).

如果你没有使用mixins,那么使用Compass并没有太大的好处,但是如果你不使用它们,那么使用SCSS并没有多大好处(嵌套和变量很好,但mixins有助于保持特定于浏览器)在单个位置实现属性)。

However, I found Blueprint to be more of a hassle than it is worth. I would still use Compass for the mixins, but right now compatibility between Rails 3.1 and Compass is terrible (you have to jump through some hoops and you still sacrifice some functionality).

但是,我发现Blueprint比它的价值更麻烦。我仍然会使用Compass作为mixins,但是现在Rails 3.1和Compass之间的兼容性非常糟糕(你必须跳过一些箍,你仍然会牺牲一些功能)。

In a somewhat related note, the way Rails 3.1 compiles assets is rather "broken". It doesn't consider how the community has been using Sass for the last year or two — keeping variables, mixins, and page partials all separate to be included by a master file in order. The "automatic" way Sprockets loads and compiles Sass disassociates files from each other, so even if you define the load order manually in your application.css, variables you set in a file are not available to subsequently loaded files.

在一个有点相关的说明中,Rails 3.1编译资产的方式相当“破碎”。它没有考虑社区在过去一两年中如何使用Sass - 保持变量,mixins和页面部分都是分开的,以便主文件按顺序包含。 “自动”方式Sprockets加载并编译Sass将文件彼此解除关联,因此即使您在application.css中手动定义加载顺序,您在文件中设置的变量也不可用于随后加载的文件。

#3


1  

Compass is a design-agnostic framework - e.g. you don't have to worry about which browsers the users have.

Compass是一个与设计无关的框架 - 例如您不必担心用户拥有哪些浏览器。

e.g. Compass has add-ons, like for example the CSS3 cross-browser features: http://compass-style.org/reference/compass/css3/ this way you can specify things in your .scss files browser-independent

例如Compass有附加组件,例如CSS3跨浏览器功能:http://compass-style.org/reference/compass/css3/这样你可以在.scss文件中指定与浏览器无关的东西

Side-Note:

边注:

The way Rails 3.1 processes .scss files, is one at a time -- e.g. if you define variables in one file, they don't get carried over to the other .scss files. IMHO not really optimal solution.

Rails 3.1处理.scss文件的方式是一次一个 - 例如如果您在一个文件中定义变量,它们不会被转移到其他.scss文件。恕我直言不是最佳解决方案。

#4


1  

The html5boilerplate compass plugin is a great time-saver too, so for these reasons I would use compass

html5boilerplate指南针插件也是一个很好的节省时间,所以出于这些原因我会使用指南针


推荐阅读
author-avatar
44要和自己交个朋友
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有