开发者

What is the value of Compass for Rails 3.1?

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 now supports SCSS di开发者_开发问答rectly. 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.

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


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.

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

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

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.


Bourbon (by Thoughtbot) is a light alternative to compass that integrates well with rails 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.

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!

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 :-) )


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

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

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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜