xass 0.1.4 → 0.1.5
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/README.md +57 -12
- data/lib/xass/view_helpers.rb +13 -5
- data/xass.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91cfa8d6349fb9b1c422658bfa51dfce7bbb3369
|
4
|
+
data.tar.gz: fe6a51357fcaf0c52173456f36b8ae36cb52d2bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51707b1166fba15c5f3cce1d1e7a8c9a236f4442e58020501ad80a311945a5a3fe02f4b435d5666f01d9cea36db326b57cb7bacb800a641bef80bc10099aba55
|
7
|
+
data.tar.gz: 7e89a7255db79d49eb970e7c9d825a495bca1cba1f513d820a3ac387a683071fd444c66884832691ef953f0b19536f91e606d57054370e8add2bc78baf5cd0ed
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
##DESCRIPTION
|
2
2
|
|
3
|
-
Xass
|
3
|
+
Xass extends Rails with namespacing CSS classes in Sass.
|
4
4
|
|
5
5
|
##INSTALLATION
|
6
6
|
|
@@ -37,7 +37,7 @@ This emits the following css.
|
|
37
37
|
}
|
38
38
|
```
|
39
39
|
|
40
|
-
|
40
|
+
In view, use helpers to apply the style.
|
41
41
|
|
42
42
|
```haml
|
43
43
|
-# /app/views/someview.html.haml
|
@@ -46,18 +46,27 @@ And,
|
|
46
46
|
%div{ class: ns(:hogehoge) }
|
47
47
|
```
|
48
48
|
|
49
|
-
|
49
|
+
This emits
|
50
50
|
|
51
|
-
|
51
|
+
```html
|
52
|
+
<div class="hoge__piyo__fuga___hogehoge"></div>
|
53
|
+
```
|
52
54
|
|
53
|
-
|
55
|
+
As matter of course, `namespace` can be nested as follows.
|
54
56
|
|
55
|
-
```
|
56
|
-
|
57
|
+
```haml
|
58
|
+
-# /app/views/someview.html.haml
|
57
59
|
|
58
|
-
|
60
|
+
= namespace :hoge do
|
61
|
+
= namespace :piyo do
|
62
|
+
= namespace :fuga do
|
63
|
+
%div{ class: ns(:hogehoge) }
|
59
64
|
```
|
60
65
|
|
66
|
+
###Example 2
|
67
|
+
|
68
|
+
You can use `root` class for convenience.
|
69
|
+
|
61
70
|
```sass
|
62
71
|
// /app/assets/stylesheets/main/hoge/piyo/fuga.sass
|
63
72
|
|
@@ -68,7 +77,7 @@ You can use `root` class for convenience.
|
|
68
77
|
width: 100px
|
69
78
|
```
|
70
79
|
|
71
|
-
This emits
|
80
|
+
This emits
|
72
81
|
|
73
82
|
```css
|
74
83
|
.hoge__piyo__fuga {
|
@@ -90,7 +99,15 @@ And,
|
|
90
99
|
%div{ class: ns(:hogehoge) }
|
91
100
|
```
|
92
101
|
|
93
|
-
|
102
|
+
This emits
|
103
|
+
|
104
|
+
```html
|
105
|
+
<div class="hoge__piyo__fuga">
|
106
|
+
<div class="hoge__piyo__fuga___hogehoge"></div>
|
107
|
+
</div>
|
108
|
+
```
|
109
|
+
|
110
|
+
Abbreviately, you can write this as follows.
|
94
111
|
|
95
112
|
```haml
|
96
113
|
-# /app/views/someview.html.haml
|
@@ -101,7 +118,7 @@ You can also write as follows abbreviately.
|
|
101
118
|
|
102
119
|
###Example 3
|
103
120
|
|
104
|
-
You can use `_` prefix
|
121
|
+
You can use `_` prefix to disable namespacing.
|
105
122
|
|
106
123
|
```sass
|
107
124
|
// /app/assets/stylesheets/application.sass
|
@@ -136,4 +153,32 @@ This emits the following css.
|
|
136
153
|
.current {
|
137
154
|
background-color: black;
|
138
155
|
}
|
139
|
-
```
|
156
|
+
```
|
157
|
+
|
158
|
+
###Example 4
|
159
|
+
|
160
|
+
In partial, you may want to reset current namespace. `namespace!` and `namespace_with_root!` do this.
|
161
|
+
|
162
|
+
```haml
|
163
|
+
-# /app/views/someview.html.haml
|
164
|
+
|
165
|
+
= namespace_with_root :hoge, :piyo, :fuga do
|
166
|
+
= render partial: 'partial'
|
167
|
+
```
|
168
|
+
|
169
|
+
```haml
|
170
|
+
-# /app/views/partial.html.haml
|
171
|
+
|
172
|
+
= namespace_with_root! :foo do
|
173
|
+
foo
|
174
|
+
```
|
175
|
+
|
176
|
+
This emits
|
177
|
+
|
178
|
+
```html
|
179
|
+
<div class="hoge__piyo__fuga">
|
180
|
+
<div class="foo">
|
181
|
+
foo
|
182
|
+
</div>
|
183
|
+
</div>
|
184
|
+
```
|
data/lib/xass/view_helpers.rb
CHANGED
@@ -18,7 +18,7 @@ module Xass
|
|
18
18
|
|
19
19
|
def namespace_with_root(*names, tag: :div, attrs: {}, reset: false, &block)
|
20
20
|
nss = reset ? [] : namespaces
|
21
|
-
content_tag(tag, namespace(*names, reset: reset, &block), attrs_with_additional_class(attrs, ns_root(nss +
|
21
|
+
content_tag(tag, namespace(*names, reset: reset, &block), attrs_with_additional_class(attrs, ns_root!(*(nss.flatten + names))))
|
22
22
|
end
|
23
23
|
|
24
24
|
def namespace_with_root!(*names, tag: :div, attrs: {}, &block)
|
@@ -41,12 +41,20 @@ module Xass
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
def ns_root(
|
45
|
-
|
44
|
+
def ns_root(*names)
|
45
|
+
ns_root!(*(namespaces.flatten + names))
|
46
46
|
end
|
47
47
|
|
48
|
-
def
|
49
|
-
|
48
|
+
def ns_root!(*names)
|
49
|
+
names.map(&:to_s).join('__')
|
50
|
+
end
|
51
|
+
|
52
|
+
def ns(*names)
|
53
|
+
"#{ns_root(*names[0...-1])}___#{names[-1]}"
|
54
|
+
end
|
55
|
+
|
56
|
+
def ns!(*names)
|
57
|
+
"#{ns_root!(*names[0...-1])}___#{names[-1]}"
|
50
58
|
end
|
51
59
|
|
52
60
|
private
|
data/xass.gemspec
CHANGED
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.1.
|
4
|
+
version: 0.1.5
|
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-08-
|
11
|
+
date: 2014-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|