xass 0.2.0 → 0.3.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.
- checksums.yaml +4 -4
- data/Gemfile.lock +7 -7
- data/README.md +37 -38
- data/lib/xass.rb +26 -32
- data/xass.gemspec +2 -2
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b92f761f31b78611e6fb903d0405ea97624e899f
|
4
|
+
data.tar.gz: d33d71d2a47b26f5c07efa014a4c83902ead0538
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a90d64d429b02e361cc3c94556c52f8502f3df55726f6e21d2b2681f51114fb59a51d1b4f6675c103cb079378bc9a14f86695fc4ac04553c98daf7801943d519
|
7
|
+
data.tar.gz: 7047ae1e555ff7e838d4d849c71ab55bb58e769e32085426d612534e6e3bb6842bf794cedf4ee60b089165b702d907cb1c08ce7fd0ef42d4046ee50a121dbbce
|
data/Gemfile.lock
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
xass (0.
|
4
|
+
xass (0.3.0)
|
5
5
|
activesupport (~> 4.0)
|
6
6
|
csspool
|
7
7
|
nokogiri
|
8
|
-
sass
|
8
|
+
sass (= 3.4.7)
|
9
9
|
|
10
10
|
GEM
|
11
11
|
remote: https://rubygems.org/
|
@@ -38,7 +38,7 @@ GEM
|
|
38
38
|
tzinfo (~> 1.1)
|
39
39
|
arel (5.0.1.20140414130214)
|
40
40
|
builder (3.2.2)
|
41
|
-
csspool (4.0.
|
41
|
+
csspool (4.0.2)
|
42
42
|
diff-lcs (1.2.5)
|
43
43
|
erubis (2.7.0)
|
44
44
|
haml (4.0.5)
|
@@ -49,11 +49,11 @@ GEM
|
|
49
49
|
mail (2.6.1)
|
50
50
|
mime-types (>= 1.16, < 3)
|
51
51
|
mime-types (2.3)
|
52
|
-
mini_portile (0.6.
|
52
|
+
mini_portile (0.6.1)
|
53
53
|
minitest (5.4.1)
|
54
54
|
multi_json (1.10.1)
|
55
|
-
nokogiri (1.6.
|
56
|
-
mini_portile (
|
55
|
+
nokogiri (1.6.4.1)
|
56
|
+
mini_portile (~> 0.6.0)
|
57
57
|
rack (1.5.2)
|
58
58
|
rack-test (0.6.2)
|
59
59
|
rack (>= 1.0)
|
@@ -85,7 +85,7 @@ GEM
|
|
85
85
|
rspec-mocks (3.1.0)
|
86
86
|
rspec-support (~> 3.1.0)
|
87
87
|
rspec-support (3.1.0)
|
88
|
-
sass (3.4.
|
88
|
+
sass (3.4.7)
|
89
89
|
sprockets (2.12.2)
|
90
90
|
hike (~> 1.2)
|
91
91
|
multi_json (~> 1.0)
|
data/README.md
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
Xass extends Rails with namespacing CSS classes in Sass.
|
4
4
|
|
5
|
+
##SUPPORT
|
6
|
+
|
7
|
+
Currently supported sass version is 3.2.19
|
8
|
+
|
5
9
|
##INSTALLATION
|
6
10
|
|
7
11
|
We suppose you use Rails with sass-rails.
|
@@ -14,7 +18,7 @@ gem 'xass'
|
|
14
18
|
|
15
19
|
##USAGE
|
16
20
|
|
17
|
-
###
|
21
|
+
###Namespacing by directory tree
|
18
22
|
|
19
23
|
```sass
|
20
24
|
// /app/assets/stylesheets/application.sass
|
@@ -29,7 +33,7 @@ gem 'xass'
|
|
29
33
|
width: 100px
|
30
34
|
```
|
31
35
|
|
32
|
-
This emits the following css
|
36
|
+
This emits the following css (notice that there are three underscores before `hogehoge`.)
|
33
37
|
|
34
38
|
```css
|
35
39
|
.hoge__piyo__fuga___hogehoge {
|
@@ -37,13 +41,14 @@ This emits the following css.
|
|
37
41
|
}
|
38
42
|
```
|
39
43
|
|
40
|
-
In view, use helpers to apply the style.
|
44
|
+
In view, use helpers or `ns` prefixed class names to apply the style.
|
41
45
|
|
42
46
|
```haml
|
43
47
|
-# /app/views/someview.html.haml
|
44
48
|
|
45
49
|
= namespace :hoge, :piyo, :fuga do
|
46
|
-
|
50
|
+
.ns-hogehoge
|
51
|
+
-# or %div{ class: ns(:hogehoge) }
|
47
52
|
```
|
48
53
|
|
49
54
|
This emits
|
@@ -60,21 +65,25 @@ As matter of course, `namespace` can be nested as follows.
|
|
60
65
|
= namespace :hoge do
|
61
66
|
= namespace :piyo do
|
62
67
|
= namespace :fuga do
|
63
|
-
|
68
|
+
.ns-hogehoge
|
64
69
|
```
|
65
70
|
|
66
|
-
|
71
|
+
If you don't want to dig namespaces, you can specify namespaces directly in `ns` prefixed class name.
|
67
72
|
|
68
|
-
|
73
|
+
```haml
|
74
|
+
= namespace :hoge do
|
75
|
+
.ns-piyo--fuga--hogehoge
|
76
|
+
```
|
77
|
+
|
78
|
+
###Special class name `root`
|
79
|
+
|
80
|
+
You can use `root` class for specify a root class name.
|
69
81
|
|
70
82
|
```sass
|
71
83
|
// /app/assets/stylesheets/main/hoge/piyo/fuga.sass
|
72
84
|
|
73
85
|
.root
|
74
86
|
width: 10px
|
75
|
-
|
76
|
-
.hogehoge
|
77
|
-
width: 100px
|
78
87
|
```
|
79
88
|
|
80
89
|
This emits
|
@@ -83,10 +92,6 @@ This emits
|
|
83
92
|
.hoge__piyo__fuga {
|
84
93
|
width: 10px;
|
85
94
|
}
|
86
|
-
|
87
|
-
.hoge__piyo__fuga___hogehoge {
|
88
|
-
width: 100px;
|
89
|
-
}
|
90
95
|
```
|
91
96
|
|
92
97
|
And,
|
@@ -95,16 +100,14 @@ And,
|
|
95
100
|
-# /app/views/someview.html.haml
|
96
101
|
|
97
102
|
= namespace :hoge, :piyo, :fuga do
|
98
|
-
|
99
|
-
|
103
|
+
.nsr
|
104
|
+
-# or %div{ class: nsr }
|
100
105
|
```
|
101
106
|
|
102
107
|
This emits
|
103
108
|
|
104
109
|
```html
|
105
|
-
<div class="hoge__piyo__fuga">
|
106
|
-
<div class="hoge__piyo__fuga___hogehoge"></div>
|
107
|
-
</div>
|
110
|
+
<div class="hoge__piyo__fuga"></div>
|
108
111
|
```
|
109
112
|
|
110
113
|
Abbreviately, you can write this as follows.
|
@@ -112,11 +115,10 @@ Abbreviately, you can write this as follows.
|
|
112
115
|
```haml
|
113
116
|
-# /app/views/someview.html.haml
|
114
117
|
|
115
|
-
= namespace_with_root :hoge, :piyo, :fuga
|
116
|
-
%div{ class: ns(:hogehoge) }
|
118
|
+
= namespace_with_root :hoge, :piyo, :fuga
|
117
119
|
```
|
118
120
|
|
119
|
-
###
|
121
|
+
###Disable namespacing
|
120
122
|
|
121
123
|
You can use `_` prefix to disable namespacing.
|
122
124
|
|
@@ -129,12 +131,6 @@ You can use `_` prefix to disable namespacing.
|
|
129
131
|
```sass
|
130
132
|
// /app/assets/stylesheets/main/hoge/piyo/fuga.sass
|
131
133
|
|
132
|
-
.root
|
133
|
-
width: 10px
|
134
|
-
|
135
|
-
.hogehoge
|
136
|
-
width: 100px
|
137
|
-
|
138
134
|
._current
|
139
135
|
background-color: black
|
140
136
|
```
|
@@ -142,20 +138,12 @@ You can use `_` prefix to disable namespacing.
|
|
142
138
|
This emits the following css.
|
143
139
|
|
144
140
|
```css
|
145
|
-
.hoge__piyo__fuga {
|
146
|
-
width: 10px;
|
147
|
-
}
|
148
|
-
|
149
|
-
.hoge__piyo__fuga___hogehoge {
|
150
|
-
width: 100px;
|
151
|
-
}
|
152
|
-
|
153
141
|
.current {
|
154
142
|
background-color: black;
|
155
143
|
}
|
156
144
|
```
|
157
145
|
|
158
|
-
###
|
146
|
+
###Reset current namespace
|
159
147
|
|
160
148
|
In partial, you may want to reset current namespace. `namespace!` and `namespace_with_root!` do this.
|
161
149
|
|
@@ -167,7 +155,7 @@ In partial, you may want to reset current namespace. `namespace!` and `namespace
|
|
167
155
|
```
|
168
156
|
|
169
157
|
```haml
|
170
|
-
-# /app/views/
|
158
|
+
-# /app/views/_partial.html.haml
|
171
159
|
|
172
160
|
= namespace_with_root! :foo do
|
173
161
|
foo
|
@@ -182,3 +170,14 @@ This emits
|
|
182
170
|
</div>
|
183
171
|
</div>
|
184
172
|
```
|
173
|
+
|
174
|
+
###Abbreviations
|
175
|
+
|
176
|
+
The following aliases are available.
|
177
|
+
|
178
|
+
```ruby
|
179
|
+
alias :dns :namespace
|
180
|
+
alias :dns! :namespace!
|
181
|
+
alias :dnsr :namespace_with_root
|
182
|
+
alias :dnsr! :namespace_with_root!
|
183
|
+
```
|
data/lib/xass.rb
CHANGED
@@ -3,43 +3,37 @@ require_relative 'initialize'
|
|
3
3
|
module Sass::Tree
|
4
4
|
class Visitors::Perform
|
5
5
|
def visit_mixin(node)
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
@environment.stack.with_mixin(node.filename, node.line, node.name) do
|
7
|
+
mixin = @environment.mixin(node.name)
|
8
|
+
raise Sass::SyntaxError.new("Undefined mixin '#{node.name}'.") unless mixin
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
if node.children.any? && !mixin.has_content
|
14
|
-
raise Sass::SyntaxError.new(%Q{Mixin "#{node.name}" does not accept a content block.})
|
15
|
-
end
|
10
|
+
if node.children.any? && !mixin.has_content
|
11
|
+
raise Sass::SyntaxError.new(%Q{Mixin "#{node.name}" does not accept a content block.})
|
12
|
+
end
|
16
13
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
14
|
+
args = node.args.map {|a| a.perform(@environment)}
|
15
|
+
keywords = Sass::Util.map_vals(node.keywords) {|v| v.perform(@environment)}
|
16
|
+
splat = self.class.perform_splat(node.splat, keywords, node.kwarg_splat, @environment)
|
17
|
+
|
18
|
+
self.class.perform_arguments(mixin, args, splat, @environment) do |env|
|
19
|
+
env.caller = Sass::Environment.new(@environment)
|
20
|
+
env.content = [node.children, @environment] if node.has_children
|
21
|
+
|
22
|
+
trace_node = Sass::Tree::TraceNode.from_node(node.name, node)
|
23
|
+
with_environment(env) {
|
24
|
+
trace_node.children = mixin.tree.map { |c|
|
25
|
+
d = c.deep_copy
|
26
|
+
xass_recursive_set_filename(d, node.filename)
|
27
|
+
visit(c)
|
28
|
+
}.flatten
|
29
|
+
}
|
30
|
+
trace_node
|
31
|
+
end
|
34
32
|
end
|
35
33
|
rescue Sass::SyntaxError => e
|
36
|
-
|
37
|
-
|
38
|
-
e.add_backtrace(:line => node.line)
|
39
|
-
end
|
34
|
+
e.modify_backtrace(:mixin => node.name, :line => node.line)
|
35
|
+
e.add_backtrace(:line => node.line)
|
40
36
|
raise e
|
41
|
-
ensure
|
42
|
-
@stack.pop unless include_loop
|
43
37
|
end
|
44
38
|
|
45
39
|
private
|
data/xass.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'xass'
|
3
|
-
s.version = '0.
|
3
|
+
s.version = '0.3.0'
|
4
4
|
s.authors = ['Tetsuri Moriya']
|
5
5
|
s.email = ['tetsuri.moriya@gmail.com']
|
6
6
|
s.summary = 'Sass namespace extension'
|
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.add_development_dependency 'rails', '>= 0'
|
13
13
|
s.add_development_dependency 'haml', '>= 0'
|
14
14
|
s.add_runtime_dependency 'activesupport', '~> 4.0'
|
15
|
-
s.add_runtime_dependency 'sass', '
|
15
|
+
s.add_runtime_dependency 'sass', '= 3.4.7'
|
16
16
|
s.add_runtime_dependency 'csspool', '>= 0'
|
17
17
|
s.add_runtime_dependency 'nokogiri', '>= 0'
|
18
18
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xass
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tetsuri Moriya
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -70,16 +70,16 @@ dependencies:
|
|
70
70
|
name: sass
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - '='
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 3.4.7
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - '='
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 3.4.7
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: csspool
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|