classnames-rails-view 0.1.1 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +11 -11
- data/lib/classnames-rails-view.rb +1 -0
- data/lib/classnames/rails/view/railtie.rb +1 -1
- data/lib/classnames/rails/view/version.rb +1 -1
- metadata +14 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f7b68268254790e28a671f42b1e53698404e6116101d6ff745dd25c12675fe09
|
4
|
+
data.tar.gz: ff3f340df7174a36772d8abcea984b296803da59d632d2cf88713cd5835d1a4c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dfdf1f88525e72f69455c2e507dfc4dcfd4db18a82b384d24344c0e775be292581893594273d4957da22ce6cf6c72632f8a0d6c3f05315799438f61e54cd6e13
|
7
|
+
data.tar.gz: a49c0fe626d5ac42789bd4ee3000b8facc28cab34035c4d028b33e418dd2d3405d293d2e83d0da3f5092195569659db4b26f1ecc105715e1e3508998eb2b0fe5
|
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
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'classnames/rails/view'
|
@@ -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,29 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: classnames-rails-view
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masamoto Miyata
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '5.0'
|
20
|
+
- - "<="
|
18
21
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
22
|
+
version: '6.1'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '5.0'
|
30
|
+
- - "<="
|
25
31
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
32
|
+
version: '6.1'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: pry-byebug
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -133,6 +139,7 @@ files:
|
|
133
139
|
- MIT-LICENSE
|
134
140
|
- README.md
|
135
141
|
- Rakefile
|
142
|
+
- lib/classnames-rails-view.rb
|
136
143
|
- lib/classnames/rails/view.rb
|
137
144
|
- lib/classnames/rails/view/action_view.rb
|
138
145
|
- lib/classnames/rails/view/core.rb
|
@@ -158,8 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
158
165
|
- !ruby/object:Gem::Version
|
159
166
|
version: '0'
|
160
167
|
requirements: []
|
161
|
-
|
162
|
-
rubygems_version: 2.6.14
|
168
|
+
rubygems_version: 3.0.6
|
163
169
|
signing_key:
|
164
170
|
specification_version: 4
|
165
171
|
summary: The helper method to dynamically generate class attribute of HTML tag.
|