xass 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2d8414b98758d82aeb2cbb007ff5a75c3235bd9b
4
- data.tar.gz: 7a6901d2a61939efa3c1e9a0ae963ffeca57284c
3
+ metadata.gz: 91cfa8d6349fb9b1c422658bfa51dfce7bbb3369
4
+ data.tar.gz: fe6a51357fcaf0c52173456f36b8ae36cb52d2bc
5
5
  SHA512:
6
- metadata.gz: 68f5cf3d0135b3d443d42dce4e4c87211b37602c69fd7578d0850dcce1e962bc15c29066ad8662d652171b54fd5f5c1137b38c95947e72d0aaccedc22bad13fb
7
- data.tar.gz: abd363ab0915631ca0c08904fe8e15e9f28fb0b712443bbb92b558efdcf9f965a07f030d15ca1cb8abcf31f903677c9729be3eb35d618a8b7ffa1485058b5fd3
6
+ metadata.gz: 51707b1166fba15c5f3cce1d1e7a8c9a236f4442e58020501ad80a311945a5a3fe02f4b435d5666f01d9cea36db326b57cb7bacb800a641bef80bc10099aba55
7
+ data.tar.gz: 7e89a7255db79d49eb970e7c9d825a495bca1cba1f513d820a3ac387a683071fd444c66884832691ef953f0b19536f91e606d57054370e8add2bc78baf5cd0ed
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ##DESCRIPTION
2
2
 
3
- Xass extend Rails with namespacing Sass classes
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
- And,
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
- Then, you can apply `width: 100px` to the `div` element.
49
+ This emits
50
50
 
51
- ###Example 2
51
+ ```html
52
+ <div class="hoge__piyo__fuga___hogehoge"></div>
53
+ ```
52
54
 
53
- You can use `root` class for convenience.
55
+ As matter of course, `namespace` can be nested as follows.
54
56
 
55
- ```sass
56
- // /app/assets/stylesheets/application.sass
57
+ ```haml
58
+ -# /app/views/someview.html.haml
57
59
 
58
- @import ./main/**/*
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 the following css.
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
- You can also write as follows abbreviately.
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 for unnamespaced .
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
+ ```
@@ -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 + [names])))
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(nss = namespaces)
45
- nss.flatten.map(&:to_s).join('__')
44
+ def ns_root(*names)
45
+ ns_root!(*(namespaces.flatten + names))
46
46
  end
47
47
 
48
- def ns(name)
49
- "#{ns_root}___#{name}"
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
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'xass'
3
- s.version = '0.1.4'
3
+ s.version = '0.1.5'
4
4
  s.authors = ['Tetsuri Moriya']
5
5
  s.email = ['tetsuri.moriya@gmail.com']
6
6
  s.summary = 'Sass namespace extension'
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
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-22 00:00:00.000000000 Z
11
+ date: 2014-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec