sprockets-sass 0.4.3 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +11 -3
- data/lib/sprockets/sass/functions.rb +19 -14
- data/lib/sprockets/sass/sass_template.rb +18 -1
- data/lib/sprockets/sass/version.rb +1 -1
- data/lib/sprockets/sass.rb +11 -14
- data/sprockets-sass.gemspec +8 -8
- metadata +68 -28
data/README.md
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
sprockets-sass
|
2
2
|
==============
|
3
3
|
|
4
|
-
**Better Sass integration with [Sprockets 2.
|
4
|
+
**Better Sass integration with [Sprockets 2.x](http://github.com/sstephenson/sprockets)**
|
5
5
|
|
6
|
-
When using Sprockets 2.
|
6
|
+
When using Sprockets 2.x with Sass you will eventually run into a pretty big issue. `//= require` directives will not allow Sass mixins, variables, etc. to be shared between files. So you'll try to use `@import`, and that'll also blow up in your face. `sprockets-sass` fixes all of this by creating a Sass::Importer that is Sprockets aware.
|
7
7
|
|
8
8
|
_Note: This works in Rails 3.1, thanks to the [sass-rails gem](http://github.com/rails/sass-rails). But if you want to use Sprockets and Sass anywhere else, like Sinatra, use `sprockets-sass`._
|
9
9
|
|
@@ -131,7 +131,15 @@ button {
|
|
131
131
|
Asset Path Sass Functions
|
132
132
|
-------------------------
|
133
133
|
|
134
|
-
As of version 0.4.0, asset path helpers have been added.
|
134
|
+
As of version 0.4.0, asset path helpers have been added. In order to use them you must add [sprockets-helpers](https://github.com/petebrowne/sprockets-helpers) to your Gemfile:
|
135
|
+
|
136
|
+
``` ruby
|
137
|
+
gem "sprockets-sass", "~> 0.5"
|
138
|
+
gem "sprockets-helpers", "~> 0.2"
|
139
|
+
# etc...
|
140
|
+
```
|
141
|
+
|
142
|
+
Here's a quick guide to setting up sprockets-helpers in your application (look at the project's [README](https://github.com/petebrowne/sprockets-helpers/blob/master/README.md) for more information):
|
135
143
|
|
136
144
|
``` ruby
|
137
145
|
map "/assets" do
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require "sass"
|
2
2
|
require "sprockets-helpers"
|
3
3
|
|
4
|
-
module
|
5
|
-
module
|
4
|
+
module Sprockets
|
5
|
+
module Sass
|
6
6
|
module Functions
|
7
7
|
# Using Sprockets::Helpers#asset_path, return the full path
|
8
8
|
# for the given +source+ as a Sass String. This supports keyword
|
@@ -14,9 +14,8 @@ module Sass
|
|
14
14
|
# background: url(asset-path("image.jpg", $digest: true)); // background: url("/assets/image-27a8f1f96afd8d4c67a59eb9447f45bd.jpg");
|
15
15
|
#
|
16
16
|
def asset_path(source, options = {})
|
17
|
-
Script::String.new context.asset_path(source.value, map_options(options)), :string
|
17
|
+
::Sass::Script::String.new context.asset_path(source.value, map_options(options)), :string
|
18
18
|
end
|
19
|
-
declare :asset_path, [:source], :var_kwargs => true
|
20
19
|
|
21
20
|
# Using Sprockets::Helpers#asset_path, return the url CSS
|
22
21
|
# for the given +source+ as a Sass String. This supports keyword
|
@@ -28,9 +27,8 @@ module Sass
|
|
28
27
|
# background: asset-url("image.jpg", $digest: true); // background: url("/assets/image-27a8f1f96afd8d4c67a59eb9447f45bd.jpg");
|
29
28
|
#
|
30
29
|
def asset_url(source, options = {})
|
31
|
-
Script::String.new "url(#{asset_path(source, options)})"
|
30
|
+
::Sass::Script::String.new "url(#{asset_path(source, options)})"
|
32
31
|
end
|
33
|
-
declare :asset_url, [:source], :var_kwargs => true
|
34
32
|
|
35
33
|
# Using Sprockets::Helpers#image_path, return the full path
|
36
34
|
# for the given +source+ as a Sass String. This supports keyword
|
@@ -42,9 +40,8 @@ module Sass
|
|
42
40
|
# background: url(image-path("image.jpg", $digest: true)); // background: url("/assets/image-27a8f1f96afd8d4c67a59eb9447f45bd.jpg");
|
43
41
|
#
|
44
42
|
def image_path(source, options = {})
|
45
|
-
Script::String.new context.image_path(source.value, map_options(options)), :string
|
43
|
+
::Sass::Script::String.new context.image_path(source.value, map_options(options)), :string
|
46
44
|
end
|
47
|
-
declare :image_path, [:source], :var_kwargs => true
|
48
45
|
|
49
46
|
# Using Sprockets::Helpers#image_path, return the url CSS
|
50
47
|
# for the given +source+ as a Sass String. This supports keyword
|
@@ -67,12 +64,8 @@ module Sass
|
|
67
64
|
options = {}
|
68
65
|
end
|
69
66
|
end
|
70
|
-
Script::String.new "url(#{image_path(source, options)})"
|
67
|
+
::Sass::Script::String.new "url(#{image_path(source, options)})"
|
71
68
|
end
|
72
|
-
declare :image_url, [:source], :var_kwargs => true
|
73
|
-
declare :image_url, [:path]
|
74
|
-
declare :image_url, [:path, :only_path]
|
75
|
-
declare :image_url, [:path, :only_path, :cache_buster]
|
76
69
|
|
77
70
|
protected
|
78
71
|
|
@@ -85,10 +78,22 @@ module Sass
|
|
85
78
|
# Returns an options hash where the keys are symbolized
|
86
79
|
# and the values are unwrapped Sass literals.
|
87
80
|
def map_options(options = {}) # :nodoc:
|
88
|
-
Sass::Util.map_hash(options) do |key, value|
|
81
|
+
::Sass::Util.map_hash(options) do |key, value|
|
89
82
|
[key.to_sym, value.respond_to?(:value) ? value.value : value]
|
90
83
|
end
|
91
84
|
end
|
92
85
|
end
|
93
86
|
end
|
94
87
|
end
|
88
|
+
|
89
|
+
module Sass::Script::Functions
|
90
|
+
include Sprockets::Sass::Functions
|
91
|
+
|
92
|
+
# Hack to ensure the Compass API signatures don't take precedence
|
93
|
+
@signatures[:image_url] = []
|
94
|
+
|
95
|
+
declare :asset_path, [:source], :var_kwargs => true
|
96
|
+
declare :asset_url, [:source], :var_kwargs => true
|
97
|
+
declare :image_path, [:source], :var_kwargs => true
|
98
|
+
declare :image_url, [:source], :var_kwargs => true, :var_args => true
|
99
|
+
end
|
@@ -8,10 +8,27 @@ module Sprockets
|
|
8
8
|
# A reference to the current Sprockets context
|
9
9
|
attr_reader :context
|
10
10
|
|
11
|
+
# Templates are initialized once the
|
12
|
+
def self.engine_initialized?
|
13
|
+
super && defined?(@@sass_functions_added)
|
14
|
+
end
|
15
|
+
|
11
16
|
# Add the Sass functions if they haven't already been added.
|
12
17
|
def initialize_engine
|
13
18
|
super
|
14
|
-
|
19
|
+
|
20
|
+
if Sass.add_sass_functions
|
21
|
+
begin
|
22
|
+
require "sprockets/sass/functions"
|
23
|
+
rescue LoadError
|
24
|
+
# Safely ignore load issues, because
|
25
|
+
# sprockets-helpers may not be available.
|
26
|
+
@@sass_functions_added = false
|
27
|
+
end
|
28
|
+
@@sass_functions_added = true
|
29
|
+
else
|
30
|
+
@@sass_functions_added = false
|
31
|
+
end
|
15
32
|
end
|
16
33
|
|
17
34
|
# Define the expected syntax for the template
|
data/lib/sprockets/sass.rb
CHANGED
@@ -7,23 +7,20 @@ module Sprockets
|
|
7
7
|
module Sass
|
8
8
|
autoload :Importer, "sprockets/sass/importer"
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
class << self
|
11
|
+
# Global configuration for `Sass::Engine` instances.
|
12
|
+
attr_accessor :options
|
13
|
+
|
14
|
+
# When false, the asset path helpers provided by
|
15
|
+
# sprockets-helpers will not be added as Sass functions.
|
16
|
+
# `true` by default.
|
17
|
+
attr_accessor :add_sass_functions
|
13
18
|
end
|
19
|
+
|
20
|
+
@options = {}
|
21
|
+
@add_sass_functions = true
|
14
22
|
end
|
15
23
|
|
16
|
-
# Register the new templates
|
17
24
|
register_engine ".sass", Sass::SassTemplate
|
18
25
|
register_engine ".scss", Sass::ScssTemplate
|
19
|
-
|
20
|
-
# Attempt to add the Sass Functions
|
21
|
-
begin
|
22
|
-
require "sass"
|
23
|
-
require "sprockets/sass/functions"
|
24
|
-
rescue LoadError
|
25
|
-
# fail silently...
|
26
|
-
end
|
27
26
|
end
|
28
|
-
|
29
|
-
|
data/sprockets-sass.gemspec
CHANGED
@@ -18,13 +18,13 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
19
|
s.require_paths = ["lib"]
|
20
20
|
|
21
|
-
s.add_dependency "sprockets",
|
22
|
-
s.add_dependency "
|
23
|
-
s.
|
24
|
-
s.add_development_dependency "
|
25
|
-
s.add_development_dependency "
|
26
|
-
s.add_development_dependency "
|
27
|
-
s.add_development_dependency "sass",
|
28
|
-
s.add_development_dependency "compass",
|
21
|
+
s.add_dependency "sprockets", "~> 2.0"
|
22
|
+
s.add_dependency "tilt", "~> 1.1"
|
23
|
+
s.add_development_dependency "appraisal", "~> 0.4"
|
24
|
+
s.add_development_dependency "rspec", "~> 2.6"
|
25
|
+
s.add_development_dependency "test-construct", "~> 1.2"
|
26
|
+
s.add_development_dependency "sprockets-helpers", "~> 0.2"
|
27
|
+
s.add_development_dependency "sass", "~> 3.1"
|
28
|
+
s.add_development_dependency "compass", "~> 0.11"
|
29
29
|
s.add_development_dependency "rake"
|
30
30
|
end
|
metadata
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sprockets-sass
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 11
|
4
5
|
prerelease:
|
5
|
-
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 5
|
9
|
+
- 0
|
10
|
+
version: 0.5.0
|
6
11
|
platform: ruby
|
7
12
|
authors:
|
8
13
|
- Pete Browne
|
@@ -10,107 +15,142 @@ autorequire:
|
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
17
|
|
13
|
-
date: 2011-11-
|
18
|
+
date: 2011-11-29 00:00:00 Z
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
|
-
name: sprockets
|
17
21
|
requirement: &id001 !ruby/object:Gem::Requirement
|
18
22
|
none: false
|
19
23
|
requirements:
|
20
24
|
- - ~>
|
21
25
|
- !ruby/object:Gem::Version
|
26
|
+
hash: 3
|
27
|
+
segments:
|
28
|
+
- 2
|
29
|
+
- 0
|
22
30
|
version: "2.0"
|
23
|
-
|
31
|
+
name: sprockets
|
24
32
|
prerelease: false
|
25
33
|
version_requirements: *id001
|
34
|
+
type: :runtime
|
26
35
|
- !ruby/object:Gem::Dependency
|
27
|
-
name: sprockets-helpers
|
28
36
|
requirement: &id002 !ruby/object:Gem::Requirement
|
29
37
|
none: false
|
30
38
|
requirements:
|
31
39
|
- - ~>
|
32
40
|
- !ruby/object:Gem::Version
|
33
|
-
|
34
|
-
|
41
|
+
hash: 13
|
42
|
+
segments:
|
43
|
+
- 1
|
44
|
+
- 1
|
45
|
+
version: "1.1"
|
46
|
+
name: tilt
|
35
47
|
prerelease: false
|
36
48
|
version_requirements: *id002
|
49
|
+
type: :runtime
|
37
50
|
- !ruby/object:Gem::Dependency
|
38
|
-
name: tilt
|
39
51
|
requirement: &id003 !ruby/object:Gem::Requirement
|
40
52
|
none: false
|
41
53
|
requirements:
|
42
54
|
- - ~>
|
43
55
|
- !ruby/object:Gem::Version
|
44
|
-
|
45
|
-
|
56
|
+
hash: 3
|
57
|
+
segments:
|
58
|
+
- 0
|
59
|
+
- 4
|
60
|
+
version: "0.4"
|
61
|
+
name: appraisal
|
46
62
|
prerelease: false
|
47
63
|
version_requirements: *id003
|
64
|
+
type: :development
|
48
65
|
- !ruby/object:Gem::Dependency
|
49
|
-
name: appraisal
|
50
66
|
requirement: &id004 !ruby/object:Gem::Requirement
|
51
67
|
none: false
|
52
68
|
requirements:
|
53
69
|
- - ~>
|
54
70
|
- !ruby/object:Gem::Version
|
55
|
-
|
56
|
-
|
71
|
+
hash: 15
|
72
|
+
segments:
|
73
|
+
- 2
|
74
|
+
- 6
|
75
|
+
version: "2.6"
|
76
|
+
name: rspec
|
57
77
|
prerelease: false
|
58
78
|
version_requirements: *id004
|
79
|
+
type: :development
|
59
80
|
- !ruby/object:Gem::Dependency
|
60
|
-
name: rspec
|
61
81
|
requirement: &id005 !ruby/object:Gem::Requirement
|
62
82
|
none: false
|
63
83
|
requirements:
|
64
84
|
- - ~>
|
65
85
|
- !ruby/object:Gem::Version
|
66
|
-
|
67
|
-
|
86
|
+
hash: 11
|
87
|
+
segments:
|
88
|
+
- 1
|
89
|
+
- 2
|
90
|
+
version: "1.2"
|
91
|
+
name: test-construct
|
68
92
|
prerelease: false
|
69
93
|
version_requirements: *id005
|
94
|
+
type: :development
|
70
95
|
- !ruby/object:Gem::Dependency
|
71
|
-
name: test-construct
|
72
96
|
requirement: &id006 !ruby/object:Gem::Requirement
|
73
97
|
none: false
|
74
98
|
requirements:
|
75
99
|
- - ~>
|
76
100
|
- !ruby/object:Gem::Version
|
77
|
-
|
78
|
-
|
101
|
+
hash: 15
|
102
|
+
segments:
|
103
|
+
- 0
|
104
|
+
- 2
|
105
|
+
version: "0.2"
|
106
|
+
name: sprockets-helpers
|
79
107
|
prerelease: false
|
80
108
|
version_requirements: *id006
|
109
|
+
type: :development
|
81
110
|
- !ruby/object:Gem::Dependency
|
82
|
-
name: sass
|
83
111
|
requirement: &id007 !ruby/object:Gem::Requirement
|
84
112
|
none: false
|
85
113
|
requirements:
|
86
114
|
- - ~>
|
87
115
|
- !ruby/object:Gem::Version
|
116
|
+
hash: 5
|
117
|
+
segments:
|
118
|
+
- 3
|
119
|
+
- 1
|
88
120
|
version: "3.1"
|
89
|
-
|
121
|
+
name: sass
|
90
122
|
prerelease: false
|
91
123
|
version_requirements: *id007
|
124
|
+
type: :development
|
92
125
|
- !ruby/object:Gem::Dependency
|
93
|
-
name: compass
|
94
126
|
requirement: &id008 !ruby/object:Gem::Requirement
|
95
127
|
none: false
|
96
128
|
requirements:
|
97
129
|
- - ~>
|
98
130
|
- !ruby/object:Gem::Version
|
131
|
+
hash: 29
|
132
|
+
segments:
|
133
|
+
- 0
|
134
|
+
- 11
|
99
135
|
version: "0.11"
|
100
|
-
|
136
|
+
name: compass
|
101
137
|
prerelease: false
|
102
138
|
version_requirements: *id008
|
139
|
+
type: :development
|
103
140
|
- !ruby/object:Gem::Dependency
|
104
|
-
name: rake
|
105
141
|
requirement: &id009 !ruby/object:Gem::Requirement
|
106
142
|
none: false
|
107
143
|
requirements:
|
108
144
|
- - ">="
|
109
145
|
- !ruby/object:Gem::Version
|
146
|
+
hash: 3
|
147
|
+
segments:
|
148
|
+
- 0
|
110
149
|
version: "0"
|
111
|
-
|
150
|
+
name: rake
|
112
151
|
prerelease: false
|
113
152
|
version_requirements: *id009
|
153
|
+
type: :development
|
114
154
|
description: When using Sprockets 2.0 with Sass you will eventually run into a pretty big issue. `//= require` directives will not allow Sass mixins, variables, etc. to be shared between files. So you'll try to use `@import`, and that'll also blow up in your face. `sprockets-sass` fixes all of this by creating a Sass::Importer that is Sprockets aware.
|
115
155
|
email:
|
116
156
|
- me@petebrowne.com
|
@@ -155,7 +195,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
155
195
|
requirements:
|
156
196
|
- - ">="
|
157
197
|
- !ruby/object:Gem::Version
|
158
|
-
hash:
|
198
|
+
hash: 3
|
159
199
|
segments:
|
160
200
|
- 0
|
161
201
|
version: "0"
|
@@ -164,14 +204,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
164
204
|
requirements:
|
165
205
|
- - ">="
|
166
206
|
- !ruby/object:Gem::Version
|
167
|
-
hash:
|
207
|
+
hash: 3
|
168
208
|
segments:
|
169
209
|
- 0
|
170
210
|
version: "0"
|
171
211
|
requirements: []
|
172
212
|
|
173
213
|
rubyforge_project: sprockets-sass
|
174
|
-
rubygems_version: 1.8.
|
214
|
+
rubygems_version: 1.8.5
|
175
215
|
signing_key:
|
176
216
|
specification_version: 3
|
177
217
|
summary: Better Sass integration with Sprockets 2.0
|