view_component 2.26.0 → 2.26.1
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.
Potentially problematic release.
This version of view_component might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/view_component/base.rb +16 -0
- data/lib/view_component/compiler.rb +0 -22
- data/lib/view_component/slot_v2.rb +5 -1
- data/lib/view_component/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: 071c4caebc8e0dd567d8850adff146e65f6c8c1fe600b866f072d9bfa94bbc46
|
4
|
+
data.tar.gz: 64df3c2eb8d27431da23a2c628de6c9c00d7988130494d37319f4a01d653fd9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69bc43697d70dfb9b96280f47b80c06d1020fd180c01cbc6ae8c8416c3e1b97ffc6587d00741fa81743ae482a316e653790db5af2584c16baf3839a58b809195
|
7
|
+
data.tar.gz: 636d5d91edb07cb90f44e3fc21e7ee63c3c115d1f5fbf7666619205b628761028c4963c65b30a181f27fbbd0bf9539cab0ec3271a48b4d747d7a705528218f11
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,12 @@
|
|
2
2
|
|
3
3
|
## main
|
4
4
|
|
5
|
+
## 2.26.1
|
6
|
+
|
7
|
+
* Fix bug that raises when trying to use a collection before the component has been compiled.
|
8
|
+
|
9
|
+
*Blake Williams*
|
10
|
+
|
5
11
|
## 2.26.0
|
6
12
|
|
7
13
|
* Lazily evaluate component `content` in `render?`, preventing the `content` block from being evaluated when `render?` returns false.
|
data/lib/view_component/base.rb
CHANGED
@@ -324,6 +324,22 @@ module ViewComponent
|
|
324
324
|
)
|
325
325
|
end
|
326
326
|
|
327
|
+
def collection_parameter
|
328
|
+
if provided_collection_parameter
|
329
|
+
provided_collection_parameter
|
330
|
+
else
|
331
|
+
name && name.demodulize.underscore.chomp("_component").to_sym
|
332
|
+
end
|
333
|
+
end
|
334
|
+
|
335
|
+
def collection_counter_parameter
|
336
|
+
"#{collection_parameter}_counter".to_sym
|
337
|
+
end
|
338
|
+
|
339
|
+
def counter_argument_present?
|
340
|
+
instance_method(:initialize).parameters.map(&:second).include?(collection_counter_parameter)
|
341
|
+
end
|
342
|
+
|
327
343
|
private
|
328
344
|
|
329
345
|
def initialize_parameter_names
|
@@ -24,28 +24,6 @@ module ViewComponent
|
|
24
24
|
)
|
25
25
|
end
|
26
26
|
|
27
|
-
# Remove any existing singleton methods,
|
28
|
-
# as Ruby warns when redefining a method.
|
29
|
-
component_class.remove_possible_singleton_method(:collection_parameter)
|
30
|
-
component_class.remove_possible_singleton_method(:collection_counter_parameter)
|
31
|
-
component_class.remove_possible_singleton_method(:counter_argument_present?)
|
32
|
-
|
33
|
-
component_class.define_singleton_method(:collection_parameter) do
|
34
|
-
if provided_collection_parameter
|
35
|
-
provided_collection_parameter
|
36
|
-
else
|
37
|
-
name.demodulize.underscore.chomp("_component").to_sym
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
component_class.define_singleton_method(:collection_counter_parameter) do
|
42
|
-
"#{collection_parameter}_counter".to_sym
|
43
|
-
end
|
44
|
-
|
45
|
-
component_class.define_singleton_method(:counter_argument_present?) do
|
46
|
-
instance_method(:initialize).parameters.map(&:second).include?(collection_counter_parameter)
|
47
|
-
end
|
48
|
-
|
49
27
|
if raise_errors
|
50
28
|
component_class.validate_initialization_parameters!
|
51
29
|
component_class.validate_collection_parameter!
|
@@ -28,7 +28,11 @@ module ViewComponent
|
|
28
28
|
@content = view_context.capture do
|
29
29
|
if defined?(@_component_instance)
|
30
30
|
# render_in is faster than `parent.render`
|
31
|
-
@
|
31
|
+
if defined?(@_content_block)
|
32
|
+
@_component_instance.render_in(view_context, &@_content_block)
|
33
|
+
else
|
34
|
+
@_component_instance.render_in(view_context)
|
35
|
+
end
|
32
36
|
elsif defined?(@_content)
|
33
37
|
@_content
|
34
38
|
elsif defined?(@_content_block)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: view_component
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.26.
|
4
|
+
version: 2.26.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitHub Open Source
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-02-
|
11
|
+
date: 2021-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|