checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
---
2
2
SHA256:
3
- metadata.gz: 59f02a9bdd999da01d26a2f7a9c80d0ec6cd1cf96d0195f8d2aa983f504d9908
4
- data.tar.gz: ea36b326f6c565cf64acc827449dc11372a2bf10c49a77b5e994d9597234e926
3
+ metadata.gz: 88f41dda27814dde34bc2c802388e04ff4e96d02cd107b455406583d19fe93ee
4
+ data.tar.gz: 4f968af602146f71ec2749455090c80db72099e0668f2961520cdf9918924ecd
5
5
SHA512:
6
- metadata.gz: e87095b78618384e60884166c0a6eb9d024c94afe0f5e4d44b1295dd5fbdf8a84000e304d8c4b56e51e8c6112f6416718fe04667b9e13bca4b2a5283c6346b49
7
- data.tar.gz: '08dc5a1408d730948c08239a90edea25cfde9cc144a7e4b24ecfd4ee6817f7a49c19df7acec9fdfd58b26545c8fe182080dc436f3ac9aa14b17479365a40166b'
6
+ metadata.gz: 5076c4abed4915eb568eb423918ce9a8c66af85f1290a7a1c6ec7858d82db515e6731f66b0135ad8208ae6cf7da5ca554b45faa12cad09487b1516cc25a09709
7
+ data.tar.gz: a4d4040ae40657644b51971393b9ba0de2e4df7bfb47fbeb685f49fc1526d92bd15a2aa542be952b04aeb7b986d2b74a4568fc2cda9a3a82470cef6f1c05c947
data/.github/workflows/ruby_on_rails.yml CHANGED
@@ -7,8 +7,17 @@ jobs:
7
7
runs-on: ubuntu-latest
8
8
strategy:
9
9
matrix:
10
- rails_version: ["5.2.3", "6.0.0", "master"]
11
- ruby_version: ["2.5.x", "2.6.x"]
10
+ rails_version: [5.0.0, 5.2.3, 6.0.0, master]
11
+ ruby_version: [2.3.x, 2.4.x, 2.5.x, 2.6.x]
12
+ exclude:
13
+ - rails_version: master
14
+ ruby_version: 2.4.x
15
+ - rails_version: master
16
+ ruby_version: 2.3.x
17
+ - rails_version: 6.0.0
18
+ ruby_version: 2.4.x
19
+ - rails_version: 6.0.0
20
+ ruby_version: 2.3.x
12
21
steps:
13
22
- uses: actions/checkout@master
14
23
- name: Setup Ruby
@@ -17,7 +26,7 @@ jobs:
17
26
version: ${{ matrix.ruby_version }}
18
27
- name: Build and test with Rake
19
28
run: |
20
- gem install bundler
29
+ gem install bundler:1.14.0
21
30
bundle update
22
31
bundle install --jobs 4 --retry 3
23
32
bundle exec rake
data/CHANGELOG.md CHANGED
@@ -1,7 +1,31 @@
1
- * Components now inherit from ActionView::Component::base
1
+ # v1.2.1
2
+
3
+ * `actionview-component` is now tested against Ruby 2.3/2.4 and Rails 5.0.0.
4
+
5
+ # v1.2.0
6
+
7
+ * The `render_component` test helper has been renamed to `render_inline`. `render_component` has been deprecated and will be removed in v2.0.0.
8
+
9
+ *Joel Hawksley*
10
+
11
+ * Components are now rendered with `render MyComponent, foo: :bar` syntax. The existing `render MyComponent.new(foo: :bar)` syntax has been deprecated and will be removed in v2.0.0.
12
+
13
+ *Joel Hawksley*
14
+
15
+ # v1.1.0
16
+
17
+ * Components now inherit from ActionView::Component::Base
2
18
3
19
*Joel Hawksley*
4
20
21
+ # v1.0.1
22
+
5
23
* Always recompile component templates outside production.
6
24
7
25
*Joel Hawksley, John Hawthorn*
26
+
27
+ # v1.0.0
28
+
29
+ This release extracts the `ActionView::Component` library from the GitHub application.
30
+
31
+ It will be published on RubyGems under the existing `actionview-component` gem name, as @chancancode has passed us ownership of the gem.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
PATH
2
2
remote: .
3
3
specs:
4
- actionview-component (1.0.1)
4
+ actionview-component (1.2.1)
5
5
6
6
GEM
7
7
remote: https://rubygems.org/
@@ -72,7 +72,7 @@ GEM
72
72
mimemagic (0.3.3)
73
73
mini_mime (1.0.2)
74
74
mini_portile2 (2.4.0)
75
- minitest (5.11.3)
75
+ minitest (5.1.0)
76
76
nio4r (2.4.0)
77
77
nokogiri (1.10.4)
78
78
mini_portile2 (~> 2.4.0)
@@ -149,7 +149,7 @@ DEPENDENCIES
149
149
actionview-component!
150
150
bundler (>= 1.14)
151
151
haml (~> 5)
152
- minitest (~> 5.0)
152
+ minitest (= 5.1.0)
153
153
rails (= 5.2.3)
154
154
rake (~> 10.0)
155
155
rubocop (~> 0.59)
@@ -157,4 +157,4 @@ DEPENDENCIES
157
157
slim (~> 4.0)
158
158
159
159
BUNDLED WITH
160
- 2.0.2
160
+ 1.17.3
data/README.md CHANGED
@@ -11,7 +11,7 @@ Preliminary support for rendering components was merged into Rails `6.1.0.alpha`
11
11
12
12
## Compatibility
13
13
14
- `actionview-component` is tested for compatibility with all combinations of Ruby `2.5`/`2.6` and Rails `5.2.3`/`6.0.0`/`6.1.0.alpha`.
14
+ `actionview-component` is tested for compatibility with combinations of Ruby `2.3`/`2.4`/`2.5`/`2.6` and Rails `5.0.0`/`5.2.3`/`6.0.0`/`6.1.0.alpha`.
15
15
16
16
## Installation
17
17
Add this line to your application's Gemfile:
@@ -124,7 +124,7 @@ end
124
124
We can render it in a view as:
125
125
126
126
```erb
127
- <%= render(TestComponent.new(title: "my title")) do %>
127
+ <%= render(TestComponent, title: "my title") do %>
128
128
Hello, World!
129
129
<% end %>
130
130
```
@@ -135,12 +135,24 @@ Which returns:
135
135
<span title="my title">Hello, World!</span>
136
136
```
137
137
138
+ ##### Supported `render` syntaxes
139
+
140
+ Components can be rendered via:
141
+
142
+ `render(TestComponent, foo: :bar)`
143
+
144
+ `render(component: TestComponent, locals: { foo: :bar })`
145
+
146
+ The following syntax has been deprecated and will be removed in v2.0.0:
147
+
148
+ `render(TestComponent.new(foo: :bar)`
149
+
138
150
#### Error case
139
151
140
152
If the component is rendered with a blank title:
141
153
142
154
```erb
143
- <%= render(TestComponent.new(title: "")) do %>
155
+ <%= render(TestComponent, title: "") do %>
144
156
Hello, World!
145
157
<% end %>
146
158
```
@@ -151,7 +163,7 @@ An error will be raised:
151
163
152
164
### Testing
153
165
154
- Components are unit tested directly. The `render_component` test helper renders a component and wraps the result in `Nokogiri.HTML`, allowing us to test the component above as:
166
+ Components are unit tested directly. The `render_inline` test helper wraps the result in `Nokogiri.HTML`, allowing us to test the component above as:
155
167
156
168
```ruby
157
169
require "action_view/component/test_helpers"
@@ -162,7 +174,7 @@ class MyComponentTest < Minitest::Test
162
174
def test_render_component
163
175
assert_equal(
164
176
%(<span title="my title">Hello, World!</span>),
165
- render_component(TestComponent.new(title: "my title")) { "Hello, World!" }.css("span").to_html
177
+ render_inline(TestComponent, title: "my title") { "Hello, World!" }.css("span").to_html
166
178
)
167
179
end
168
180
end
data/actionview-component.gemspec CHANGED
@@ -6,7 +6,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
6
6
7
7
Gem::Specification.new do |spec|
8
8
spec.name = "actionview-component"
9
- spec.version = "1.1.0"
9
+ spec.version = "1.2.1"
10
10
spec.authors = ["GitHub Open Source"]
11
11
spec.email = ["opensource+actionview-component@github.com"]
12
12
@@ -31,11 +31,11 @@ Gem::Specification.new do |spec|
31
31
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
32
32
spec.require_paths = ["lib"]
33
33
34
- spec.required_ruby_version = ">= 2.5.0"
34
+ spec.required_ruby_version = ">= 2.3.0"
35
35
36
36
spec.add_development_dependency "bundler", ">= 1.14"
37
37
spec.add_development_dependency "rake", "~> 10.0"
38
- spec.add_development_dependency "minitest", "~> 5.0"
38
+ spec.add_development_dependency "minitest", "= 5.1.0"
39
39
spec.add_development_dependency "haml", "~> 5"
40
40
spec.add_development_dependency "slim", "~> 4.0"
41
41
spec.add_development_dependency "rubocop", "~> 0.59"
data/lib/action_view/component/base.rb CHANGED
@@ -2,18 +2,28 @@
2
2
3
3
# Monkey patch ActionView::Base#render to support ActionView::Component
4
4
#
5
- # Upstreamed in https://github.com/rails/rails/pull/36388
6
- # Necessary for Rails versions < 6.1.0.alpha
5
+ # A version of this monkey patch was upstreamed in https://github.com/rails/rails/pull/36388
6
+ # We'll need to upstream an updated version of this eventually.
7
7
class ActionView::Base
8
8
module RenderMonkeyPatch
9
- def render(component, _ = nil, &block)
10
- return super unless component.respond_to?(:render_in)
11
-
12
- component.render_in(self, &block)
9
+ def render(options = {}, args = {}, &block)
10
+ if options.respond_to?(:render_in)
11
+ ActiveSupport::Deprecation.warn(
12
+ "passing component instances to `render` has been deprecated and will be removed in v2.0.0. Use `render MyComponent, foo: :bar` instead."
13
+ )
14
+
15
+ options.render_in(self, &block)
16
+ elsif options.is_a?(Class) && options < ActionView::Component::Base
17
+ options.new(args).render_in(self, &block)
18
+ elsif options.is_a?(Hash) && options.has_key?(:component)
19
+ options[:component].new(options[:locals]).render_in(self, &block)
20
+ else
21
+ super
22
+ end
13
23
end
14
24
end
15
25
16
- prepend RenderMonkeyPatch unless Rails::VERSION::MINOR > 0 && Rails::VERSION::MAJOR == 6
26
+ prepend RenderMonkeyPatch
17
27
end
18
28
19
29
module ActionView
@@ -42,7 +52,7 @@ module ActionView
42
52
# <span title="<%= @title %>">Hello, <%= content %>!</span>
43
53
#
44
54
# In use:
45
- # <%= render MyComponent.new(title: "greeting") do %>world<% end %>
55
+ # <%= render MyComponent, title: "greeting" do %>world<% end %>
46
56
# returns:
47
57
# <span title="greeting">Hello, world!</span>
48
58
#
data/lib/action_view/component/test_helpers.rb CHANGED
@@ -3,8 +3,16 @@
3
3
module ActionView
4
4
module Component
5
5
module TestHelpers
6
- def render_component(component, &block)
7
- Nokogiri::HTML(component.render_in(ApplicationController.new.view_context, &block))
6
+ def render_inline(component, **args, &block)
7
+ Nokogiri::HTML(ApplicationController.new.view_context.render(component, args, &block))
8
+ end
9
+
10
+ def render_component(component, **args, &block)
11
+ ActiveSupport::Deprecation.warn(
12
+ "`render_component` has been deprecated in favor of `render_inline`, and will be removed in v2.0.0."
13
+ )
14
+
15
+ render_inline(component, args, &block)
8
16
end
9
17
end
10
18
end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
--- !ruby/object:Gem::Specification
2
2
name: actionview-component
3
3
version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.1
5
5
platform: ruby
6
6
authors:
7
7
- GitHub Open Source
8
8
autorequire:
9
9
bindir: exe
10
10
cert_chain: []
11
- date: 2019-08-27 00:00:00.000000000 Z
11
+ date: 2019-08-28 00:00:00.000000000 Z
12
12
dependencies:
13
13
- !ruby/object:Gem::Dependency
14
14
name: bundler
@@ -42,16 +42,16 @@ dependencies:
42
42
name: minitest
43
43
requirement: !ruby/object:Gem::Requirement
44
44
requirements:
45
- - - "~>"
45
+ - - '='
46
46
- !ruby/object:Gem::Version
47
- version: '5.0'
47
+ version: 5.1.0
48
48
type: :development
49
49
prerelease: false
50
50
version_requirements: !ruby/object:Gem::Requirement
51
51
requirements:
52
- - - "~>"
52
+ - - '='
53
53
- !ruby/object:Gem::Version
54
- version: '5.0'
54
+ version: 5.1.0
55
55
- !ruby/object:Gem::Dependency
56
56
name: haml
57
57
requirement: !ruby/object:Gem::Requirement
@@ -147,7 +147,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
147
147
requirements:
148
148
- - ">="
149
149
- !ruby/object:Gem::Version
150
- version: 2.5.0
150
+ version: 2.3.0
151
151
required_rubygems_version: !ruby/object:Gem::Requirement
152
152
requirements:
153
153
- - ">="