actionview-component 1.1.0 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ruby_on_rails.yml +13 -4
- data/CHANGELOG.md +43 -1
- data/CONTRIBUTING.md +1 -1
- data/Gemfile +1 -1
- data/Gemfile.lock +63 -47
- data/README.md +21 -5
- data/actionview-component.gemspec +3 -3
- data/lib/action_view/component/base.rb +35 -9
- data/lib/action_view/component/test_helpers.rb +14 -2
- metadata +7 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7670fc77a362e27fd4b9d666c20c2042bb077a3a7c3211bca3271074af4ea913
|
|
4
|
+
data.tar.gz: 7fbd76e8c88ea4e44386e329dd187573dfc7553e371088053e8ec2645c0bad3f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: be88328b943bc8aa3d4d1a05e845b53c77e3a6737e8e863b94c349ec3049d47bf25c4610ebbc812e2f2ecb84568ec787eb2e86cae622d5c3a2d81a7bce000655
|
|
7
|
+
data.tar.gz: a489fc157813dc6ac67bc8bd047b487234768c4584449128bd9290582507da75d68fb429a5ed9bfd9e75b80b29e21549a793de76a00f784a07a63657f12f6ad5
|
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
name: Ruby on Rails
|
|
2
2
|
|
|
3
|
-
on: [push]
|
|
3
|
+
on: [push, pull_request]
|
|
4
4
|
|
|
5
5
|
jobs:
|
|
6
6
|
build:
|
|
7
7
|
runs-on: ubuntu-latest
|
|
8
8
|
strategy:
|
|
9
9
|
matrix:
|
|
10
|
-
rails_version: [
|
|
11
|
-
ruby_version: [
|
|
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,49 @@
|
|
|
1
|
-
|
|
1
|
+
# v1.3.2
|
|
2
|
+
|
|
3
|
+
* Support rendering views from inside component templates.
|
|
4
|
+
|
|
5
|
+
*Patrick Sinclair*
|
|
6
|
+
|
|
7
|
+
# v1.3.1
|
|
8
|
+
|
|
9
|
+
* Fix bug where rendering nested content caused an error.
|
|
10
|
+
|
|
11
|
+
*Joel Hawksley, Aaron Patterson*
|
|
12
|
+
|
|
13
|
+
# v1.3.0
|
|
14
|
+
|
|
15
|
+
* Components are rendered with enough controller context to support rendering of partials and forms.
|
|
16
|
+
|
|
17
|
+
*Patrick Sinclair, Joel Hawksley, Aaron Patterson*
|
|
18
|
+
|
|
19
|
+
# v1.2.1
|
|
20
|
+
|
|
21
|
+
* `actionview-component` is now tested against Ruby 2.3/2.4 and Rails 5.0.0.
|
|
22
|
+
|
|
23
|
+
# v1.2.0
|
|
24
|
+
|
|
25
|
+
* The `render_component` test helper has been renamed to `render_inline`. `render_component` has been deprecated and will be removed in v2.0.0.
|
|
2
26
|
|
|
3
27
|
*Joel Hawksley*
|
|
4
28
|
|
|
29
|
+
* 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.
|
|
30
|
+
|
|
31
|
+
*Joel Hawksley*
|
|
32
|
+
|
|
33
|
+
# v1.1.0
|
|
34
|
+
|
|
35
|
+
* Components now inherit from ActionView::Component::Base
|
|
36
|
+
|
|
37
|
+
*Joel Hawksley*
|
|
38
|
+
|
|
39
|
+
# v1.0.1
|
|
40
|
+
|
|
5
41
|
* Always recompile component templates outside production.
|
|
6
42
|
|
|
7
43
|
*Joel Hawksley, John Hawthorn*
|
|
44
|
+
|
|
45
|
+
# v1.0.0
|
|
46
|
+
|
|
47
|
+
This release extracts the `ActionView::Component` library from the GitHub application.
|
|
48
|
+
|
|
49
|
+
It will be published on RubyGems under the existing `actionview-component` gem name, as @chancancode has passed us ownership of the gem.
|
data/CONTRIBUTING.md
CHANGED
|
@@ -32,6 +32,7 @@ Here are a few things you can do that will increase the likelihood of your pull
|
|
|
32
32
|
If you are the current maintainer of this gem:
|
|
33
33
|
|
|
34
34
|
1. Create a branch for the release: `git checkout -b release-vxx.xx.xx`
|
|
35
|
+
1. Bump gem version in `actionview-component.gemspec`.
|
|
35
36
|
1. Make sure your local dependencies are up to date: `bundle`
|
|
36
37
|
1. Ensure that tests are green: `bundle exec rake`
|
|
37
38
|
1. Build a test gem `GEM_VERSION=$(git describe --tags 2>/dev/null | sed 's/-/./g' | sed 's/v//') gem build actionview-component.gemspec`
|
|
@@ -39,7 +40,6 @@ If you are the current maintainer of this gem:
|
|
|
39
40
|
1. Bump the Gemfile and Gemfile.lock versions for an app which relies on this gem
|
|
40
41
|
1. Install the new gem locally
|
|
41
42
|
1. Test behavior locally, branch deploy, whatever needs to happen
|
|
42
|
-
1. Bump gem version in `actionview-component.gemspec`.
|
|
43
43
|
1. Make a PR to github/actionview-component.
|
|
44
44
|
1. Build a local gem: `gem build actionview-component.gemspec`
|
|
45
45
|
1. Merge github/actionview-component PR
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,53 +1,66 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
actionview-component (1.
|
|
4
|
+
actionview-component (1.3.2)
|
|
5
5
|
|
|
6
6
|
GEM
|
|
7
7
|
remote: https://rubygems.org/
|
|
8
8
|
specs:
|
|
9
|
-
actioncable (
|
|
10
|
-
actionpack (=
|
|
9
|
+
actioncable (6.0.0)
|
|
10
|
+
actionpack (= 6.0.0)
|
|
11
11
|
nio4r (~> 2.0)
|
|
12
12
|
websocket-driver (>= 0.6.1)
|
|
13
|
-
|
|
14
|
-
actionpack (=
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
actionmailbox (6.0.0)
|
|
14
|
+
actionpack (= 6.0.0)
|
|
15
|
+
activejob (= 6.0.0)
|
|
16
|
+
activerecord (= 6.0.0)
|
|
17
|
+
activestorage (= 6.0.0)
|
|
18
|
+
activesupport (= 6.0.0)
|
|
19
|
+
mail (>= 2.7.1)
|
|
20
|
+
actionmailer (6.0.0)
|
|
21
|
+
actionpack (= 6.0.0)
|
|
22
|
+
actionview (= 6.0.0)
|
|
23
|
+
activejob (= 6.0.0)
|
|
17
24
|
mail (~> 2.5, >= 2.5.4)
|
|
18
25
|
rails-dom-testing (~> 2.0)
|
|
19
|
-
actionpack (
|
|
20
|
-
actionview (=
|
|
21
|
-
activesupport (=
|
|
26
|
+
actionpack (6.0.0)
|
|
27
|
+
actionview (= 6.0.0)
|
|
28
|
+
activesupport (= 6.0.0)
|
|
22
29
|
rack (~> 2.0)
|
|
23
30
|
rack-test (>= 0.6.3)
|
|
24
31
|
rails-dom-testing (~> 2.0)
|
|
25
|
-
rails-html-sanitizer (~> 1.0, >= 1.0
|
|
26
|
-
|
|
27
|
-
|
|
32
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
|
33
|
+
actiontext (6.0.0)
|
|
34
|
+
actionpack (= 6.0.0)
|
|
35
|
+
activerecord (= 6.0.0)
|
|
36
|
+
activestorage (= 6.0.0)
|
|
37
|
+
activesupport (= 6.0.0)
|
|
38
|
+
nokogiri (>= 1.8.5)
|
|
39
|
+
actionview (6.0.0)
|
|
40
|
+
activesupport (= 6.0.0)
|
|
28
41
|
builder (~> 3.1)
|
|
29
42
|
erubi (~> 1.4)
|
|
30
43
|
rails-dom-testing (~> 2.0)
|
|
31
|
-
rails-html-sanitizer (~> 1.
|
|
32
|
-
activejob (
|
|
33
|
-
activesupport (=
|
|
44
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
|
45
|
+
activejob (6.0.0)
|
|
46
|
+
activesupport (= 6.0.0)
|
|
34
47
|
globalid (>= 0.3.6)
|
|
35
|
-
activemodel (
|
|
36
|
-
activesupport (=
|
|
37
|
-
activerecord (
|
|
38
|
-
activemodel (=
|
|
39
|
-
activesupport (=
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
activerecord (=
|
|
48
|
+
activemodel (6.0.0)
|
|
49
|
+
activesupport (= 6.0.0)
|
|
50
|
+
activerecord (6.0.0)
|
|
51
|
+
activemodel (= 6.0.0)
|
|
52
|
+
activesupport (= 6.0.0)
|
|
53
|
+
activestorage (6.0.0)
|
|
54
|
+
actionpack (= 6.0.0)
|
|
55
|
+
activejob (= 6.0.0)
|
|
56
|
+
activerecord (= 6.0.0)
|
|
44
57
|
marcel (~> 0.3.1)
|
|
45
|
-
activesupport (
|
|
58
|
+
activesupport (6.0.0)
|
|
46
59
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
47
60
|
i18n (>= 0.7, < 2)
|
|
48
61
|
minitest (~> 5.1)
|
|
49
62
|
tzinfo (~> 1.1)
|
|
50
|
-
|
|
63
|
+
zeitwerk (~> 2.1, >= 2.1.8)
|
|
51
64
|
ast (2.4.0)
|
|
52
65
|
builder (3.2.3)
|
|
53
66
|
concurrent-ruby (1.1.5)
|
|
@@ -72,8 +85,8 @@ GEM
|
|
|
72
85
|
mimemagic (0.3.3)
|
|
73
86
|
mini_mime (1.0.2)
|
|
74
87
|
mini_portile2 (2.4.0)
|
|
75
|
-
minitest (5.
|
|
76
|
-
nio4r (2.
|
|
88
|
+
minitest (5.1.0)
|
|
89
|
+
nio4r (2.5.2)
|
|
77
90
|
nokogiri (1.10.4)
|
|
78
91
|
mini_portile2 (~> 2.4.0)
|
|
79
92
|
parallel (1.17.0)
|
|
@@ -82,30 +95,32 @@ GEM
|
|
|
82
95
|
rack (2.0.7)
|
|
83
96
|
rack-test (1.1.0)
|
|
84
97
|
rack (>= 1.0, < 3)
|
|
85
|
-
rails (
|
|
86
|
-
actioncable (=
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
98
|
+
rails (6.0.0)
|
|
99
|
+
actioncable (= 6.0.0)
|
|
100
|
+
actionmailbox (= 6.0.0)
|
|
101
|
+
actionmailer (= 6.0.0)
|
|
102
|
+
actionpack (= 6.0.0)
|
|
103
|
+
actiontext (= 6.0.0)
|
|
104
|
+
actionview (= 6.0.0)
|
|
105
|
+
activejob (= 6.0.0)
|
|
106
|
+
activemodel (= 6.0.0)
|
|
107
|
+
activerecord (= 6.0.0)
|
|
108
|
+
activestorage (= 6.0.0)
|
|
109
|
+
activesupport (= 6.0.0)
|
|
95
110
|
bundler (>= 1.3.0)
|
|
96
|
-
railties (=
|
|
111
|
+
railties (= 6.0.0)
|
|
97
112
|
sprockets-rails (>= 2.0.0)
|
|
98
113
|
rails-dom-testing (2.0.3)
|
|
99
114
|
activesupport (>= 4.2.0)
|
|
100
115
|
nokogiri (>= 1.6)
|
|
101
116
|
rails-html-sanitizer (1.2.0)
|
|
102
117
|
loofah (~> 2.2, >= 2.2.2)
|
|
103
|
-
railties (
|
|
104
|
-
actionpack (=
|
|
105
|
-
activesupport (=
|
|
118
|
+
railties (6.0.0)
|
|
119
|
+
actionpack (= 6.0.0)
|
|
120
|
+
activesupport (= 6.0.0)
|
|
106
121
|
method_source
|
|
107
122
|
rake (>= 0.8.7)
|
|
108
|
-
thor (>= 0.
|
|
123
|
+
thor (>= 0.20.3, < 2.0)
|
|
109
124
|
rainbow (3.0.0)
|
|
110
125
|
rake (10.5.0)
|
|
111
126
|
rubocop (0.74.0)
|
|
@@ -141,6 +156,7 @@ GEM
|
|
|
141
156
|
websocket-driver (0.7.1)
|
|
142
157
|
websocket-extensions (>= 0.1.0)
|
|
143
158
|
websocket-extensions (0.1.4)
|
|
159
|
+
zeitwerk (2.1.10)
|
|
144
160
|
|
|
145
161
|
PLATFORMS
|
|
146
162
|
ruby
|
|
@@ -149,12 +165,12 @@ DEPENDENCIES
|
|
|
149
165
|
actionview-component!
|
|
150
166
|
bundler (>= 1.14)
|
|
151
167
|
haml (~> 5)
|
|
152
|
-
minitest (
|
|
153
|
-
rails (=
|
|
168
|
+
minitest (= 5.1.0)
|
|
169
|
+
rails (= 6.0.0)
|
|
154
170
|
rake (~> 10.0)
|
|
155
171
|
rubocop (~> 0.59)
|
|
156
172
|
rubocop-github (~> 0.13.0)
|
|
157
173
|
slim (~> 4.0)
|
|
158
174
|
|
|
159
175
|
BUNDLED WITH
|
|
160
|
-
|
|
176
|
+
1.17.3
|
data/README.md
CHANGED
|
@@ -9,9 +9,13 @@ This gem is meant to serve as a precursor to upstreaming the `ActionView::Compon
|
|
|
9
9
|
|
|
10
10
|
Preliminary support for rendering components was merged into Rails `6.1.0.alpha` in https://github.com/rails/rails/pull/36388. Assuming `ActionView::Component` makes it into Rails `6.1`, this gem will then exist to serve as a backport.
|
|
11
11
|
|
|
12
|
+
## Design philosophy
|
|
13
|
+
|
|
14
|
+
As the goal of this gem is to be upstreamed into Rails, it is designed to integrate as seamlessly as possible, with the [least surprise](https://www.artima.com/intv/ruby4.html).
|
|
15
|
+
|
|
12
16
|
## Compatibility
|
|
13
17
|
|
|
14
|
-
`actionview-component` is tested for compatibility with
|
|
18
|
+
`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
19
|
|
|
16
20
|
## Installation
|
|
17
21
|
Add this line to your application's Gemfile:
|
|
@@ -124,7 +128,7 @@ end
|
|
|
124
128
|
We can render it in a view as:
|
|
125
129
|
|
|
126
130
|
```erb
|
|
127
|
-
<%= render(TestComponent
|
|
131
|
+
<%= render(TestComponent, title: "my title") do %>
|
|
128
132
|
Hello, World!
|
|
129
133
|
<% end %>
|
|
130
134
|
```
|
|
@@ -135,12 +139,24 @@ Which returns:
|
|
|
135
139
|
<span title="my title">Hello, World!</span>
|
|
136
140
|
```
|
|
137
141
|
|
|
142
|
+
##### Supported `render` syntaxes
|
|
143
|
+
|
|
144
|
+
Components can be rendered via:
|
|
145
|
+
|
|
146
|
+
`render(TestComponent, foo: :bar)`
|
|
147
|
+
|
|
148
|
+
`render(component: TestComponent, locals: { foo: :bar })`
|
|
149
|
+
|
|
150
|
+
The following syntax has been deprecated and will be removed in v2.0.0:
|
|
151
|
+
|
|
152
|
+
`render(TestComponent.new(foo: :bar)`
|
|
153
|
+
|
|
138
154
|
#### Error case
|
|
139
155
|
|
|
140
156
|
If the component is rendered with a blank title:
|
|
141
157
|
|
|
142
158
|
```erb
|
|
143
|
-
<%= render(TestComponent
|
|
159
|
+
<%= render(TestComponent, title: "") do %>
|
|
144
160
|
Hello, World!
|
|
145
161
|
<% end %>
|
|
146
162
|
```
|
|
@@ -151,7 +167,7 @@ An error will be raised:
|
|
|
151
167
|
|
|
152
168
|
### Testing
|
|
153
169
|
|
|
154
|
-
Components are unit tested directly. The `
|
|
170
|
+
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
171
|
|
|
156
172
|
```ruby
|
|
157
173
|
require "action_view/component/test_helpers"
|
|
@@ -162,7 +178,7 @@ class MyComponentTest < Minitest::Test
|
|
|
162
178
|
def test_render_component
|
|
163
179
|
assert_equal(
|
|
164
180
|
%(<span title="my title">Hello, World!</span>),
|
|
165
|
-
|
|
181
|
+
render_inline(TestComponent, title: "my title") { "Hello, World!" }.css("span").to_html
|
|
166
182
|
)
|
|
167
183
|
end
|
|
168
184
|
end
|
|
@@ -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.
|
|
9
|
+
spec.version = "1.3.2"
|
|
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.
|
|
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", "
|
|
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"
|
|
@@ -2,24 +2,36 @@
|
|
|
2
2
|
|
|
3
3
|
# Monkey patch ActionView::Base#render to support ActionView::Component
|
|
4
4
|
#
|
|
5
|
-
#
|
|
6
|
-
#
|
|
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(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
|
26
|
+
prepend RenderMonkeyPatch
|
|
17
27
|
end
|
|
18
28
|
|
|
19
29
|
module ActionView
|
|
20
30
|
module Component
|
|
21
31
|
class Base < ActionView::Base
|
|
22
32
|
include ActiveModel::Validations
|
|
33
|
+
include ActiveSupport::Configurable
|
|
34
|
+
include ActionController::RequestForgeryProtection
|
|
23
35
|
|
|
24
36
|
# Entrypoint for rendering components. Called by ActionView::Base#render.
|
|
25
37
|
#
|
|
@@ -42,12 +54,18 @@ module ActionView
|
|
|
42
54
|
# <span title="<%= @title %>">Hello, <%= content %>!</span>
|
|
43
55
|
#
|
|
44
56
|
# In use:
|
|
45
|
-
# <%= render MyComponent
|
|
57
|
+
# <%= render MyComponent, title: "greeting" do %>world<% end %>
|
|
46
58
|
# returns:
|
|
47
59
|
# <span title="greeting">Hello, world!</span>
|
|
48
60
|
#
|
|
49
61
|
def render_in(view_context, *args, &block)
|
|
50
62
|
self.class.compile
|
|
63
|
+
self.controller = view_context.controller
|
|
64
|
+
@view_context = view_context
|
|
65
|
+
@view_renderer ||= view_context.view_renderer
|
|
66
|
+
@lookup_context ||= view_context.lookup_context
|
|
67
|
+
@view_flow ||= view_context.view_flow
|
|
68
|
+
|
|
51
69
|
@content = view_context.capture(&block) if block_given?
|
|
52
70
|
validate!
|
|
53
71
|
call
|
|
@@ -55,6 +73,14 @@ module ActionView
|
|
|
55
73
|
|
|
56
74
|
def initialize(*); end
|
|
57
75
|
|
|
76
|
+
def render(options = {}, args = {}, &block)
|
|
77
|
+
if options.is_a?(String) || (options.is_a?(Hash) && options.has_key?(:partial))
|
|
78
|
+
view_context.render(options, args, &block)
|
|
79
|
+
else
|
|
80
|
+
super
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
58
84
|
class << self
|
|
59
85
|
def inherited(child)
|
|
60
86
|
child.include Rails.application.routes.url_helpers unless child < Rails.application.routes.url_helpers
|
|
@@ -126,7 +152,7 @@ module ActionView
|
|
|
126
152
|
|
|
127
153
|
private
|
|
128
154
|
|
|
129
|
-
attr_reader :content
|
|
155
|
+
attr_reader :content, :view_context
|
|
130
156
|
end
|
|
131
157
|
end
|
|
132
158
|
end
|
|
@@ -3,8 +3,20 @@
|
|
|
3
3
|
module ActionView
|
|
4
4
|
module Component
|
|
5
5
|
module TestHelpers
|
|
6
|
-
def
|
|
7
|
-
Nokogiri::HTML(
|
|
6
|
+
def render_inline(component, **args, &block)
|
|
7
|
+
Nokogiri::HTML(controller.view_context.render(component, args, &block))
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def controller
|
|
11
|
+
@controller ||= ApplicationController.new.tap { |c| c.request = ActionDispatch::TestRequest.create }
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def render_component(component, **args, &block)
|
|
15
|
+
ActiveSupport::Deprecation.warn(
|
|
16
|
+
"`render_component` has been deprecated in favor of `render_inline`, and will be removed in v2.0.0."
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
render_inline(component, args, &block)
|
|
8
20
|
end
|
|
9
21
|
end
|
|
10
22
|
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.
|
|
4
|
+
version: 1.3.2
|
|
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-
|
|
11
|
+
date: 2019-10-02 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:
|
|
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:
|
|
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.
|
|
150
|
+
version: 2.3.0
|
|
151
151
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
152
152
|
requirements:
|
|
153
153
|
- - ">="
|