Paul Klumpp cd873bce75 bundle install --deployment | 12 years ago | |
---|---|---|
.. | ||
lib | 12 years ago | |
test | 12 years ago | |
.gitignore | 12 years ago | |
.travis.yml | 12 years ago | |
CHANGELOG.md | 12 years ago | |
Gemfile | 12 years ago | |
MIT-LICENSE | 12 years ago | |
README.markdown | 12 years ago | |
Rakefile | 12 years ago | |
sass-rails.gemspec | 12 years ago |
This gem provides official integration for ruby on rails projects with the Sass stylesheet language.
Since rails 3.1, new rails projects will be already configured to use Sass. If you are upgrading to rails 3.1 you will need to add the following to your Gemfile:
gem 'sass-rails'
To configure Sass via rails set use config.sass
in your
application and/or environment files to set configuration
properties that will be passed to Sass.
MyProject::Application.configure do
config.sass.line_comments = false
config.sass.syntax = :nested
end
Sprockets provides some directives that are placed inside of comments called require
, require_tree
, and
require_self
. DO NOT USE THEM IN YOUR SASS/SCSS FILES. They are very
primitive and do not work well with Sass files. Instead, use Sass's native @import
directive which
sass-rails
has customized to integrate with the conventions of your rails projects.
The list of supported options can be found on the Sass Website with the following caveats:
config.assets.compress
boolean option instead of through the :style
option.:never_update
- This option is not supported. Instead set config.assets.enabled = false
:always_update
- This option is not supported. Sprockets uses a controller to access stylesheets in development mode instead of a full scan for changed files.:always_check
- This option is not supported. Sprockets always checks in development.:syntax
- This is determined by the file's extensions.:filename
- This is determined by the file's name.:line
- This is provided by the template handler.Glob Imports. When in rails, there is a special import syntax that allows you to
glob imports relative to the folder of the stylesheet that is doing the importing.
E.g. @import "mixins/*"
will import all the files in the mixins folder and
@import "mixins/**/*"
will import all the files in the mixins tree.
Any valid ruby glob may be used. The imports are sorted alphabetically.
NOTE: It is recommended that you only use this when importing pure library
files (containing mixins and variables) because it is difficult to control the
cascade ordering for imports that contain styles using this approach.
Asset Helpers. When using the asset pipeline, paths to assets must be rewritten. When referencing assets use the following asset helpers (underscored in Ruby, hyphenated in Sass):
asset-path($relative-asset-path, $asset-class)
- Returns a string to the asset.
For example: asset-path("rails.png", image)
becomes "/assets/rails.png"
asset-url($relative-asset-path, $asset-class)
- Returns url reference to the asset.
For example: asset-url("rails.png", image)
becomes url(/assets/rails.png)
-path
and -url
helpers:
image, font, video, audio, javascript, stylesheet.
For example: image-url("rails.png")
becomes url(/assets/rails.png)
and
image-path("rails.png")
becomes "/assets/rails.png"
.asset-data-url($relative-asset-path)
- Returns url reference to the Base64-encoded asset at the specified path.
For example: asset-data-url("rails.png")
becomes url(data:image/png;base64,iVBORw0K...)
$ bundle install
$ bundle exec rake test
If you need to test against local gems, use Bundler's gem :path option in the Gemfile and also edit test/support/test_helper.rb
and tell the tests where the gem is checked out.