Skip to content

Commit bc675ce

Browse files
committed
Changed to Snake Case according to the rules of ruby.
1 parent 1fb8748 commit bc675ce

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
classnames-rails-view (0.1.3)
4+
classnames-rails-view (1.0.0)
55
rails (>= 5.0, < 5.3)
66

77
GEM

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,33 @@ This is a view helper that dynamically generates class attributes in Rails view,
66
The Helper method is included automatically, so you can use it immediately.
77

88
```erb
9-
<div class="<%= classNames('foo') %>">Hello World</div>
9+
<div class="<%= class_names('foo') %>">Hello World</div>
1010
<%# <div class="foo">Hello World</div> %>
1111
```
1212

13-
The `classNames` method takes any number of arguments which can be a string or hash.
13+
The `class_names` method takes any number of arguments which can be a string or hash.
1414
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.
1515

1616
```js
17-
classNames('foo', 'bar'); // => 'foo bar'
18-
classNames('foo', { bar: true }); // => 'foo bar'
19-
classNames({ 'foo-bar': true }); // => 'foo-bar'
20-
classNames({ 'foo-bar': false }); // => ''
21-
classNames({ foo: true }, { bar: true }); // => 'foo bar'
22-
classNames({ foo: true, bar: true }); // => 'foo bar'
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'
2323

2424
// lots of arguments of various types
25-
classNames('foo', { bar: true, duck: false }, 'baz', { quux: true }); // => 'foo bar baz quux'
25+
class_names('foo', { bar: true, duck: false }, 'baz', { quux: true }); // => 'foo bar baz quux'
2626

2727
// other falsy values are just ignored
28-
classNames(null, false, 'bar', undefined, 0, 1, { baz: null }, ''); // => 'bar 1'
28+
class_names(null, false, 'bar', undefined, 0, 1, { baz: null }, ''); // => 'bar 1'
2929
```
3030

3131
Arrays will be recursively flattened as per the rules above:
3232

3333
```js
3434
var arr = ['b', { c: true, d: false }];
35-
classNames('a', arr); // => 'a b c'
35+
class_names('a', arr); // => 'a b c'
3636
```
3737

3838
### Change the method name

lib/classnames/rails/view/railtie.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module Rails
33
module View
44
class Railtie < ::Rails::Railtie
55
config.classnames_rails_view = ActiveSupport::OrderedOptions.new
6-
config.classnames_rails_view.method_name = :classNames
6+
config.classnames_rails_view.method_name = :class_names
77

88
config.after_initialize do |_app|
99
require 'classnames/rails/view/action_view'

lib/classnames/rails/view/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module Classnames
22
module Rails
33
module View
4-
VERSION = '0.1.3'.freeze
4+
VERSION = '1.0.0'.freeze
55
end
66
end
77
end

0 commit comments

Comments
 (0)