classnames-rails-view 0.1.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -11
- data/lib/classnames/rails/view/railtie.rb +1 -1
- data/lib/classnames/rails/view/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 298692499e7c51bd97311568b503edf38e5a1f22c59c69a39d5f7a0035eb4abd
|
4
|
+
data.tar.gz: 3d853d8645dece5612773ea6305596d5ded20e13e2daa5d83df8e81dae330a38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84cebd452f5708e94660d76cfb22bb202aee75593f71fac95a2d9cc52a0d988dd8b40a01694ed118e6a65dcdb1ae4156baacfa701ebd2bdac881d4451946bef1
|
7
|
+
data.tar.gz: f1a608935661e77b1a5fed16f7001bab13a24b6e3337524dac6dea323da6bffc5f42ce72e400113a0b3c4c976237b8e0af0cd43c65e8e33e72b08a70e3bc6f76
|
data/README.md
CHANGED
@@ -6,33 +6,33 @@ This is a view helper that dynamically generates class attributes in Rails view,
|
|
6
6
|
The Helper method is included automatically, so you can use it immediately.
|
7
7
|
|
8
8
|
```erb
|
9
|
-
<div class="<%=
|
9
|
+
<div class="<%= class_names('foo') %>">Hello World</div>
|
10
10
|
<%# <div class="foo">Hello World</div> %>
|
11
11
|
```
|
12
12
|
|
13
|
-
The `
|
13
|
+
The `class_names` method takes any number of arguments which can be a string or hash.
|
14
14
|
The argument `'foo'` is short for `{ foo: true }`. If the value associated with a given key is falsy, that key won't be included in the output.
|
15
15
|
|
16
16
|
```js
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
17
|
+
class_names('foo', 'bar'); // => 'foo bar'
|
18
|
+
class_names('foo', { bar: true }); // => 'foo bar'
|
19
|
+
class_names({ 'foo-bar': true }); // => 'foo-bar'
|
20
|
+
class_names({ 'foo-bar': false }); // => ''
|
21
|
+
class_names({ foo: true }, { bar: true }); // => 'foo bar'
|
22
|
+
class_names({ foo: true, bar: true }); // => 'foo bar'
|
23
23
|
|
24
24
|
// lots of arguments of various types
|
25
|
-
|
25
|
+
class_names('foo', { bar: true, duck: false }, 'baz', { quux: true }); // => 'foo bar baz quux'
|
26
26
|
|
27
27
|
// other falsy values are just ignored
|
28
|
-
|
28
|
+
class_names(null, false, 'bar', undefined, 0, 1, { baz: null }, ''); // => 'bar 1'
|
29
29
|
```
|
30
30
|
|
31
31
|
Arrays will be recursively flattened as per the rules above:
|
32
32
|
|
33
33
|
```js
|
34
34
|
var arr = ['b', { c: true, d: false }];
|
35
|
-
|
35
|
+
class_names('a', arr); // => 'a b c'
|
36
36
|
```
|
37
37
|
|
38
38
|
### Change the method name
|
@@ -3,7 +3,7 @@ module Classnames
|
|
3
3
|
module View
|
4
4
|
class Railtie < ::Rails::Railtie
|
5
5
|
config.classnames_rails_view = ActiveSupport::OrderedOptions.new
|
6
|
-
config.classnames_rails_view.method_name = :
|
6
|
+
config.classnames_rails_view.method_name = :class_names
|
7
7
|
|
8
8
|
config.after_initialize do |_app|
|
9
9
|
require 'classnames/rails/view/action_view'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: classnames-rails-view
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masamoto Miyata
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-04-
|
11
|
+
date: 2018-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|