sass-rails 3.1.0.rc.1 → 3.1.0.rc.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +3 -4
- data/README.markdown +52 -0
- data/lib/rails/generators/sass/assets/assets_generator.rb +1 -1
- data/lib/rails/generators/sass/assets/templates/stylesheet.css.sass +4 -1
- data/lib/rails/generators/sass_scaffold.rb +2 -1
- data/lib/rails/generators/scss/assets/assets_generator.rb +1 -1
- data/lib/rails/generators/scss/assets/templates/stylesheet.css.scss +5 -1
- data/lib/sass-rails.rb +1 -31
- data/lib/sass/rails.rb +11 -0
- data/lib/sass/rails/compressor.rb +15 -0
- data/lib/sass/rails/importer.rb +128 -0
- data/lib/sass/rails/monkey_patches.rb +20 -0
- data/lib/sass/rails/railtie.rb +43 -0
- data/lib/sass/rails/template_handlers.rb +61 -0
- data/lib/{sass-rails → sass/rails}/version.rb +1 -1
- data/sass-rails.gemspec +8 -7
- data/test/fixtures/sass_project/.gitignore +5 -0
- data/test/fixtures/sass_project/Gemfile +7 -0
- data/test/fixtures/sass_project/README +261 -0
- data/test/{dummy → fixtures/sass_project}/Rakefile +2 -2
- data/test/fixtures/sass_project/app/assets/images/rails.png +0 -0
- data/test/fixtures/sass_project/app/assets/javascripts/application.js +9 -0
- data/test/fixtures/sass_project/app/assets/stylesheets/application.css +7 -0
- data/test/{dummy → fixtures/sass_project}/app/controllers/application_controller.rb +0 -0
- data/test/{dummy → fixtures/sass_project}/app/helpers/application_helper.rb +0 -0
- data/test/{dummy/public/stylesheets → fixtures/sass_project/app/mailers}/.gitkeep +0 -0
- data/test/{dummy/log/development.log → fixtures/sass_project/app/models/.gitkeep} +0 -0
- data/test/fixtures/sass_project/app/views/layouts/application.html.erb +14 -0
- data/test/{dummy → fixtures/sass_project}/config.ru +1 -1
- data/test/fixtures/sass_project/config/application.rb +52 -0
- data/test/fixtures/sass_project/config/boot.rb +6 -0
- data/test/{dummy → fixtures/sass_project}/config/database.yml +3 -0
- data/test/{dummy → fixtures/sass_project}/config/environment.rb +1 -1
- data/test/{dummy → fixtures/sass_project}/config/environments/development.rb +5 -4
- data/test/{dummy → fixtures/sass_project}/config/environments/production.rb +18 -13
- data/test/{dummy → fixtures/sass_project}/config/environments/test.rb +6 -2
- data/test/{dummy → fixtures/sass_project}/config/initializers/backtrace_silencers.rb +0 -0
- data/test/{dummy → fixtures/sass_project}/config/initializers/inflections.rb +0 -0
- data/test/{dummy → fixtures/sass_project}/config/initializers/mime_types.rb +0 -0
- data/test/{dummy → fixtures/sass_project}/config/initializers/secret_token.rb +1 -1
- data/test/{dummy → fixtures/sass_project}/config/initializers/session_store.rb +2 -2
- data/test/fixtures/sass_project/config/initializers/wrap_parameters.rb +12 -0
- data/test/{dummy → fixtures/sass_project}/config/locales/en.yml +1 -1
- data/test/{dummy → fixtures/sass_project}/config/routes.rb +2 -2
- data/test/fixtures/sass_project/db/seeds.rb +7 -0
- data/test/fixtures/sass_project/doc/README_FOR_APP +2 -0
- data/test/{dummy/log/production.log → fixtures/sass_project/lib/tasks/.gitkeep} +0 -0
- data/test/{dummy/log/server.log → fixtures/sass_project/log/.gitkeep} +0 -0
- data/test/{dummy → fixtures/sass_project}/public/404.html +0 -0
- data/test/{dummy → fixtures/sass_project}/public/422.html +0 -0
- data/test/{dummy → fixtures/sass_project}/public/500.html +0 -0
- data/test/{dummy → fixtures/sass_project}/public/favicon.ico +0 -0
- data/test/fixtures/sass_project/public/index.html +241 -0
- data/test/fixtures/sass_project/public/robots.txt +5 -0
- data/test/{dummy → fixtures/sass_project}/script/rails +0 -0
- data/test/fixtures/sass_project/vendor/assets/stylesheets/.gitkeep +0 -0
- data/test/fixtures/sass_project/vendor/plugins/.gitkeep +0 -0
- data/test/fixtures/scss_project/.gitignore +5 -0
- data/test/fixtures/scss_project/Gemfile +7 -0
- data/test/fixtures/scss_project/README +261 -0
- data/test/fixtures/scss_project/Rakefile +7 -0
- data/test/fixtures/scss_project/app/assets/images/rails.png +0 -0
- data/test/fixtures/scss_project/app/assets/javascripts/application.js +9 -0
- data/test/fixtures/scss_project/app/assets/stylesheets/_top_level_partial.css.scss +3 -0
- data/test/fixtures/scss_project/app/assets/stylesheets/application.css.scss +10 -0
- data/test/fixtures/scss_project/app/assets/stylesheets/globbed/globbed.css.scss +3 -0
- data/test/fixtures/scss_project/app/assets/stylesheets/globbed/nested/nested_glob.css.scss +3 -0
- data/test/fixtures/scss_project/app/assets/stylesheets/partials/_sass_import.css.sass +5 -0
- data/test/fixtures/scss_project/app/assets/stylesheets/partials/_scss_import.css.scss +9 -0
- data/test/fixtures/scss_project/app/assets/stylesheets/partials/subfolder/_relative_sass.css.sass +2 -0
- data/test/fixtures/scss_project/app/assets/stylesheets/partials/subfolder/_relative_scss.css.scss +3 -0
- data/test/fixtures/scss_project/app/assets/stylesheets/partials/subfolder/relative_not_a_partial.css.scss +3 -0
- data/test/fixtures/scss_project/app/assets/stylesheets/subfolder/another_plain.css +3 -0
- data/test/fixtures/scss_project/app/assets/stylesheets/subfolder/plain.css +3 -0
- data/test/fixtures/scss_project/app/assets/stylesheets/subfolder/second_level.css.scss +1 -0
- data/test/fixtures/scss_project/app/controllers/application_controller.rb +3 -0
- data/test/fixtures/scss_project/app/helpers/application_helper.rb +2 -0
- data/test/fixtures/scss_project/app/mailers/.gitkeep +0 -0
- data/test/fixtures/scss_project/app/models/.gitkeep +0 -0
- data/test/fixtures/scss_project/app/views/layouts/application.html.erb +14 -0
- data/test/fixtures/scss_project/config.ru +4 -0
- data/test/{dummy → fixtures/scss_project}/config/application.rb +13 -9
- data/test/fixtures/scss_project/config/boot.rb +6 -0
- data/test/fixtures/scss_project/config/database.yml +25 -0
- data/test/fixtures/scss_project/config/environment.rb +5 -0
- data/test/fixtures/scss_project/config/environments/development.rb +27 -0
- data/test/fixtures/scss_project/config/environments/production.rb +54 -0
- data/test/fixtures/scss_project/config/environments/test.rb +39 -0
- data/test/fixtures/scss_project/config/initializers/backtrace_silencers.rb +7 -0
- data/test/fixtures/scss_project/config/initializers/inflections.rb +10 -0
- data/test/fixtures/scss_project/config/initializers/mime_types.rb +5 -0
- data/test/fixtures/scss_project/config/initializers/secret_token.rb +7 -0
- data/test/fixtures/scss_project/config/initializers/session_store.rb +8 -0
- data/test/fixtures/scss_project/config/initializers/wrap_parameters.rb +12 -0
- data/test/fixtures/scss_project/config/locales/en.yml +5 -0
- data/test/fixtures/scss_project/config/routes.rb +58 -0
- data/test/fixtures/scss_project/db/seeds.rb +7 -0
- data/test/fixtures/scss_project/doc/README_FOR_APP +2 -0
- data/test/fixtures/scss_project/lib/tasks/.gitkeep +0 -0
- data/test/fixtures/scss_project/log/.gitkeep +0 -0
- data/test/fixtures/scss_project/public/404.html +26 -0
- data/test/fixtures/scss_project/public/422.html +26 -0
- data/test/fixtures/scss_project/public/500.html +26 -0
- data/test/fixtures/scss_project/public/favicon.ico +0 -0
- data/test/fixtures/scss_project/public/index.html +241 -0
- data/test/fixtures/scss_project/public/robots.txt +5 -0
- data/test/fixtures/scss_project/script/rails +6 -0
- data/test/fixtures/scss_project/vendor/assets/stylesheets/.gitkeep +0 -0
- data/test/fixtures/scss_project/vendor/plugins/.gitkeep +0 -0
- data/test/sass_rails_test.rb +46 -3
- data/test/support/sass_rails_test_case.rb +147 -0
- data/test/test_helper.rb +15 -11
- metadata +260 -85
- data/test/dummy/app/views/layouts/application.html.erb +0 -14
- data/test/dummy/config/boot.rb +0 -10
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/test.log +0 -4
- data/test/dummy/public/javascripts/application.js +0 -2
- data/test/dummy/public/javascripts/controls.js +0 -965
- data/test/dummy/public/javascripts/dragdrop.js +0 -974
- data/test/dummy/public/javascripts/effects.js +0 -1123
- data/test/dummy/public/javascripts/prototype.js +0 -6001
- data/test/dummy/public/javascripts/rails.js +0 -191
- data/test/integration/navigation_test.rb +0 -7
- data/test/support/integration_case.rb +0 -5
data/Gemfile
CHANGED
@@ -3,11 +3,10 @@ source "http://rubygems.org"
|
|
3
3
|
# Specify your gem's dependencies in sass-rails.gemspec
|
4
4
|
gemspec
|
5
5
|
|
6
|
-
gem "rails", :
|
7
|
-
gem "
|
8
|
-
gem "sqlite3"
|
6
|
+
gem "rails", :git => "git://github.com/rails/rails.git", :branch => "3-1-stable"
|
7
|
+
gem "sprockets"
|
9
8
|
|
10
9
|
# To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+)
|
11
10
|
# gem 'ruby-debug'
|
12
|
-
gem 'ruby-debug19'
|
11
|
+
# gem 'ruby-debug19'
|
13
12
|
|
data/README.markdown
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# Official Ruby-on-Rails Integration with Sass
|
2
|
+
|
3
|
+
This gem provides official integration for ruby on rails projects with the Sass stylesheet language.
|
4
|
+
|
5
|
+
## Installing
|
6
|
+
|
7
|
+
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:
|
8
|
+
|
9
|
+
gem 'sass-rails'
|
10
|
+
|
11
|
+
## Configuration
|
12
|
+
|
13
|
+
To configure Sass via rails set use `config.sass` in your
|
14
|
+
application and/or environment files to set configuration
|
15
|
+
properties that will be passed to Sass.
|
16
|
+
|
17
|
+
### Example
|
18
|
+
|
19
|
+
MyProject::Application.configure do
|
20
|
+
config.sass.line_comments = false
|
21
|
+
config.sass.syntax = :nested
|
22
|
+
end
|
23
|
+
|
24
|
+
### Options
|
25
|
+
|
26
|
+
The [list of supported options](http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#options) can be found on the Sass Website with the following caveats:
|
27
|
+
|
28
|
+
1. Output compression is now controlled via the `config.assets.compress` boolean option instead of through the `:style` option.
|
29
|
+
2. `:never_update` - This option is not supported. Instead set `config.assets.enabled = false`
|
30
|
+
3. `: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.
|
31
|
+
4. `:always_check` - This option is not supported. Sprockets always checks in development.
|
32
|
+
5. `:syntax` - This is determined by the file's extensions.
|
33
|
+
6. `:filename` - This is determined by the file's name.
|
34
|
+
7. `:line` - This is provided by the template handler.
|
35
|
+
|
36
|
+
## Features
|
37
|
+
|
38
|
+
* **Glob Imports**. When in rails, there is a special import syntax that allows you to
|
39
|
+
glob imports relative to the folder of the stylesheet that is doing the importing.
|
40
|
+
E.g. `@import "mixins/*"` will import all the files in the mixins folder and
|
41
|
+
`@import "mixins/**/*"` will import all the files in the mixins tree.
|
42
|
+
Any valid ruby glob may be used. The imports are sorted alphabetically.
|
43
|
+
**NOTE:** It is recommended that you only use this when importing pure library
|
44
|
+
files (containing mixins and variables) because it is difficult to control the
|
45
|
+
cascade ordering for imports that contain styles using this approach.
|
46
|
+
|
47
|
+
## Running Tests
|
48
|
+
|
49
|
+
$ bundle install
|
50
|
+
$ bundle exec rake test
|
51
|
+
|
52
|
+
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.
|
@@ -6,7 +6,7 @@ module Sass
|
|
6
6
|
source_root File.expand_path("../templates", __FILE__)
|
7
7
|
|
8
8
|
def copy_sass
|
9
|
-
|
9
|
+
template "stylesheet.css.sass", File.join('app/assets/stylesheets', class_path, "#{file_name}.css.sass")
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
@@ -1,3 +1,6 @@
|
|
1
|
-
// Place all the styles related to the
|
1
|
+
// Place all the styles related to the <%= name %> controller here.
|
2
2
|
// They will automatically be included in application.css.
|
3
3
|
// You can use Sass here: http://sass-lang.com/
|
4
|
+
|
5
|
+
body.<%= name.dasherize %>
|
6
|
+
// Place scoped styles here
|
@@ -7,7 +7,8 @@ module Sass
|
|
7
7
|
def copy_stylesheet
|
8
8
|
dir = ::Rails::Generators::ScaffoldGenerator.source_root
|
9
9
|
file = File.join(dir, "scaffold.css")
|
10
|
-
|
10
|
+
converted_contents = ::Sass::CSS.new(File.read(file)).render(syntax)
|
11
|
+
create_file "app/assets/stylesheets/scaffolds.css.#{syntax}", converted_contents
|
11
12
|
end
|
12
13
|
end
|
13
14
|
end
|
@@ -6,7 +6,7 @@ module Scss
|
|
6
6
|
source_root File.expand_path("../templates", __FILE__)
|
7
7
|
|
8
8
|
def copy_scss
|
9
|
-
|
9
|
+
template "stylesheet.css.scss", File.join('app/assets/stylesheets', class_path, "#{file_name}.css.scss")
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
@@ -1,3 +1,7 @@
|
|
1
|
-
// Place all the styles related to the
|
1
|
+
// Place all the styles related to the <%= name %> controller here.
|
2
2
|
// They will automatically be included in application.css.
|
3
3
|
// You can use Sass (SCSS) here: http://sass-lang.com/
|
4
|
+
|
5
|
+
body.<%= name.dasherize %> {
|
6
|
+
// Place scoped styles here
|
7
|
+
}
|
data/lib/sass-rails.rb
CHANGED
@@ -1,31 +1 @@
|
|
1
|
-
|
2
|
-
class CssCompressor
|
3
|
-
def compress(css)
|
4
|
-
Sass::Engine.new(css,
|
5
|
-
:syntax => :scss,
|
6
|
-
:cache => false,
|
7
|
-
:read_cache => false,
|
8
|
-
:style => :compressed).render
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
class Railtie < ::Rails::Railtie
|
13
|
-
config.sass = ActiveSupport::OrderedOptions.new
|
14
|
-
config.sass.syntax = :scss
|
15
|
-
|
16
|
-
initializer :setup_sass do |app|
|
17
|
-
syntax = app.config.sass.syntax
|
18
|
-
alt_syntax = syntax.to_s == "sass" ? "scss" : "sass"
|
19
|
-
|
20
|
-
app.config.generators.hide_namespace alt_syntax
|
21
|
-
config.app_generators.stylesheet_engine app.config.sass.syntax
|
22
|
-
end
|
23
|
-
|
24
|
-
initializer :setup_compression do |app|
|
25
|
-
if app.config.assets.compress
|
26
|
-
app.config.assets.css_compressor = CssCompressor.new
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
1
|
+
require 'sass/rails'
|
data/lib/sass/rails.rb
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
require 'sprockets'
|
2
|
+
|
3
|
+
module Sass::Rails
|
4
|
+
class Importer
|
5
|
+
GLOB = /\*|\[.+\]/
|
6
|
+
PARTIAL = /^_/
|
7
|
+
HAS_EXTENSION = /\.css(.s[ac]ss)?$/
|
8
|
+
|
9
|
+
SASS_EXTENSIONS = {
|
10
|
+
".css.sass" => :sass,
|
11
|
+
".css.scss" => :scss
|
12
|
+
}
|
13
|
+
attr_reader :context
|
14
|
+
|
15
|
+
def initialize(context)
|
16
|
+
@context = context
|
17
|
+
end
|
18
|
+
|
19
|
+
def sass_file?(filename)
|
20
|
+
filename = filename.to_s
|
21
|
+
SASS_EXTENSIONS.keys.any?{|ext| filename[ext]}
|
22
|
+
end
|
23
|
+
|
24
|
+
def syntax(filename)
|
25
|
+
filename = filename.to_s
|
26
|
+
SASS_EXTENSIONS.each {|ext, syntax| return syntax if filename[(ext.size+2)..-1][ext]}
|
27
|
+
nil
|
28
|
+
end
|
29
|
+
|
30
|
+
def resolve(name, base_pathname = nil)
|
31
|
+
name = Pathname.new(name)
|
32
|
+
if base_pathname && base_pathname.to_s.size > 0
|
33
|
+
name = base_pathname.dirname.relative_path_from(context.pathname.dirname).join(name)
|
34
|
+
end
|
35
|
+
partial_name = name.dirname.join("_#{name.basename}")
|
36
|
+
sprockets_resolve(name) || sprockets_resolve(partial_name)
|
37
|
+
end
|
38
|
+
|
39
|
+
def find_relative(name, base, options)
|
40
|
+
base_pathname = Pathname.new(base)
|
41
|
+
if name =~ GLOB
|
42
|
+
glob_imports(name, base_pathname, options)
|
43
|
+
elsif pathname = resolve(name, base_pathname)
|
44
|
+
context.depend_on(pathname)
|
45
|
+
if sass_file?(pathname)
|
46
|
+
Sass::Engine.new(pathname.read, options.merge(:filename => pathname.to_s, :importer => self, :syntax => syntax(pathname)))
|
47
|
+
else
|
48
|
+
Sass::Engine.new(sprockets_process(pathname), options.merge(:filename => pathname.to_s, :importer => self, :syntax => :scss))
|
49
|
+
end
|
50
|
+
else
|
51
|
+
nil
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def find(name, options)
|
56
|
+
if name =~ GLOB
|
57
|
+
nil # globs must be relative
|
58
|
+
elsif pathname = resolve(name)
|
59
|
+
context.depend_on(pathname)
|
60
|
+
if sass_file?(pathname)
|
61
|
+
Sass::Engine.new(pathname.read, options.merge(:filename => pathname.to_s, :importer => self, :syntax => syntax(pathname)))
|
62
|
+
else
|
63
|
+
Sass::Engine.new(sprockets_process(pathname), options.merge(:filename => pathname.to_s, :importer => self, :syntax => :scss))
|
64
|
+
end
|
65
|
+
else
|
66
|
+
nil
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def each_globbed_file(glob, base_pathname, options)
|
71
|
+
Dir["#{base_pathname.dirname}/#{glob}"].sort.each do |filename|
|
72
|
+
next if filename == options[:filename]
|
73
|
+
yield filename if File.directory?(filename) || context.asset_requirable?(filename)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def glob_imports(glob, base_pathname, options)
|
78
|
+
contents = ""
|
79
|
+
each_globbed_file(glob, base_pathname, options) do |filename|
|
80
|
+
if File.directory?(filename)
|
81
|
+
context.depend_on(filename)
|
82
|
+
elsif context.asset_requirable?(filename)
|
83
|
+
context.depend_on(filename)
|
84
|
+
contents << "@import #{Pathname.new(filename).relative_path_from(base_pathname.dirname).to_s.inspect};\n"
|
85
|
+
end
|
86
|
+
end
|
87
|
+
return nil if contents.empty?
|
88
|
+
Sass::Engine.new(contents, options.merge(
|
89
|
+
:filename => base_pathname.to_s,
|
90
|
+
:importer => self,
|
91
|
+
:syntax => :scss
|
92
|
+
))
|
93
|
+
end
|
94
|
+
|
95
|
+
def mtime(name, options)
|
96
|
+
if name =~ GLOB && options[:filename]
|
97
|
+
mtime = nil
|
98
|
+
each_globbed_file(name, Pathname.new(options[:filename]), options) do |p|
|
99
|
+
mtime ||= File.mtime(p)
|
100
|
+
mtime = [mtime, File.mtime(p)].max
|
101
|
+
end
|
102
|
+
mtime
|
103
|
+
elsif pathname = resolve(name)
|
104
|
+
pathname.mtime
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
def key(name, options)
|
109
|
+
["Sprockets:" + File.dirname(File.expand_path(name)), File.basename(name)]
|
110
|
+
end
|
111
|
+
|
112
|
+
def to_s
|
113
|
+
"Sass::Rails::Importer(#{context.pathname})"
|
114
|
+
end
|
115
|
+
|
116
|
+
private
|
117
|
+
def sprockets_resolve(path)
|
118
|
+
context.resolve(path, :content_type => :self)
|
119
|
+
rescue Sprockets::FileNotFound, Sprockets::ContentTypeMismatch
|
120
|
+
nil
|
121
|
+
end
|
122
|
+
|
123
|
+
def sprockets_process(path)
|
124
|
+
context.environment[path].to_s
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'sprockets/railtie'
|
2
|
+
|
3
|
+
module Sprockets
|
4
|
+
class Railtie < ::Rails::Railtie
|
5
|
+
|
6
|
+
module SassContext
|
7
|
+
attr_accessor :sass_config
|
8
|
+
end
|
9
|
+
|
10
|
+
protected
|
11
|
+
|
12
|
+
def asset_environment_with_sass_config(app, *args)
|
13
|
+
env = asset_environment_without_sass_config(app, *args)
|
14
|
+
env.context_class.extend(SassContext)
|
15
|
+
env.context_class.sass_config = app.config.sass
|
16
|
+
env
|
17
|
+
end
|
18
|
+
alias_method_chain :asset_environment, :sass_config
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Sass::Rails
|
2
|
+
class Railtie < ::Rails::Railtie
|
3
|
+
config.sass = ActiveSupport::OrderedOptions.new
|
4
|
+
# Establish static configuration defaults
|
5
|
+
# Emit scss files during stylesheet generation of scaffold
|
6
|
+
config.sass.preferred_syntax = :scss
|
7
|
+
# Use expanded output instead of the sass default of :nested
|
8
|
+
config.sass.style = :expanded
|
9
|
+
# Write sass cache files to tmp/sass-cache for performance
|
10
|
+
config.sass.cache = true
|
11
|
+
# Read sass cache files from tmp/sass-cache for performance
|
12
|
+
config.sass.read_cache = true
|
13
|
+
# Display line comments above each selector as a debugging aid
|
14
|
+
config.sass.line_comments = true
|
15
|
+
|
16
|
+
initializer :setup_sass do |app|
|
17
|
+
# Only emit one kind of syntax because though we have registered two kinds of generators
|
18
|
+
syntax = app.config.sass.preferred_syntax.to_sym
|
19
|
+
alt_syntax = syntax == :sass ? "scss" : "sass"
|
20
|
+
app.config.generators.hide_namespace alt_syntax
|
21
|
+
|
22
|
+
# Set the stylesheet engine to the preferred syntax
|
23
|
+
config.app_generators.stylesheet_engine syntax
|
24
|
+
|
25
|
+
# Set the sass cache location to tmp/sass-cache
|
26
|
+
config.sass.cache_location = File.join(Rails.root, "tmp/sass-cache")
|
27
|
+
|
28
|
+
# Establish configuration defaults that are evironmental in nature
|
29
|
+
if config.sass.full_exception.nil?
|
30
|
+
# Display a stack trace in the css output when in development-like environments.
|
31
|
+
config.sass.full_exception = app.config.consider_all_requests_local
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
initializer :setup_compression do |app|
|
37
|
+
if app.config.assets.compress
|
38
|
+
# Use sass's css_compressor
|
39
|
+
app.config.assets.css_compressor = CssCompressor.new
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'tilt'
|
2
|
+
require 'sprockets'
|
3
|
+
|
4
|
+
module Sass::Rails
|
5
|
+
class SassTemplate < Tilt::SassTemplate
|
6
|
+
self.default_mime_type = 'text/css'
|
7
|
+
|
8
|
+
def self.engine_initialized?
|
9
|
+
defined?(::Sass::Engine)
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize_engine
|
13
|
+
require_template_library 'sass'
|
14
|
+
end
|
15
|
+
|
16
|
+
def syntax
|
17
|
+
:sass
|
18
|
+
end
|
19
|
+
|
20
|
+
def sass_options_from_rails(scope)
|
21
|
+
scope.environment.context_class.sass_config
|
22
|
+
end
|
23
|
+
|
24
|
+
def sass_options(scope)
|
25
|
+
importer = self.importer(scope)
|
26
|
+
options = sass_options_from_rails(scope)
|
27
|
+
load_paths = (options[:load_paths] || []).dup
|
28
|
+
load_paths.unshift(importer)
|
29
|
+
options.merge(
|
30
|
+
:filename => eval_file,
|
31
|
+
:line => line,
|
32
|
+
:syntax => syntax,
|
33
|
+
:importer => importer,
|
34
|
+
:load_paths => load_paths
|
35
|
+
)
|
36
|
+
end
|
37
|
+
|
38
|
+
def importer(scope)
|
39
|
+
Sass::Rails::Importer.new(scope)
|
40
|
+
end
|
41
|
+
|
42
|
+
def prepare
|
43
|
+
end
|
44
|
+
|
45
|
+
def evaluate(scope, locals, &block)
|
46
|
+
Sass::Engine.new(data, sass_options(scope)).render
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
class ScssTemplate < SassTemplate
|
51
|
+
self.default_mime_type = 'text/css'
|
52
|
+
|
53
|
+
def syntax
|
54
|
+
:scss
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
Sprockets::Engines #invoke autoloading
|
60
|
+
Sprockets.register_engine '.sass', Sass::Rails::SassTemplate
|
61
|
+
Sprockets.register_engine '.scss', Sass::Rails::ScssTemplate
|
data/sass-rails.gemspec
CHANGED
@@ -1,22 +1,23 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
$:.push File.expand_path("../lib", __FILE__)
|
3
|
-
require "sass
|
3
|
+
require "sass/rails/version"
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = "sass-rails"
|
7
7
|
s.version = Sass::Rails::VERSION
|
8
8
|
s.platform = Gem::Platform::RUBY
|
9
|
-
s.authors = ["wycats"]
|
10
|
-
s.email = ["wycats@gmail.com"]
|
11
|
-
s.homepage = "
|
12
|
-
s.summary = %q{
|
13
|
-
s.description = %q{
|
9
|
+
s.authors = ["wycats", "chriseppstein"]
|
10
|
+
s.email = ["wycats@gmail.com", "chris@eppsteins.net"]
|
11
|
+
s.homepage = ""
|
12
|
+
s.summary = %q{Sass adapter for the Rails asset pipeline.}
|
13
|
+
s.description = %q{Sass adapter for the Rails asset pipeline.}
|
14
14
|
|
15
15
|
s.rubyforge_project = "sass-rails"
|
16
16
|
|
17
|
-
s.add_runtime_dependency 'sass', '
|
17
|
+
s.add_runtime_dependency 'sass', '>= 3.1.2'
|
18
18
|
s.add_runtime_dependency 'railties', '~> 3.1.0.rc1'
|
19
19
|
s.add_runtime_dependency 'actionpack', '~> 3.1.0.rc1'
|
20
|
+
s.add_runtime_dependency 'sprockets', '>= 2.0.0.beta.9'
|
20
21
|
|
21
22
|
s.files = `git ls-files`.split("\n")
|
22
23
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|