view_component 2.27.0 → 2.28.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of view_component might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/lib/view_component/base.rb +1 -0
- data/lib/view_component/compiler.rb +1 -1
- data/lib/view_component/engine.rb +1 -1
- data/lib/view_component/slotable.rb +2 -2
- data/lib/view_component/slotable_v2.rb +5 -1
- data/lib/view_component/version.rb +3 -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: 0abc25e32e2befb60487f209469b2d9b96d6f1380a345466bcc816addc9f65d1
|
4
|
+
data.tar.gz: a72e8ad8a5cfa1bbfd0bbbaa5510e14abd4818657b356681930537d8d5efa95e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b3f1cd9a86493fd5fbf68537536435c13b202bcba0d01e8d58f20ba0c158b7cdf1f878c75103d4b6a00f54e89227f7cb6b083bbbab17122e3e7f6b9d7c7f20d
|
7
|
+
data.tar.gz: 4a29369a237c75889bce3a0777e5ff82e2bd7d25966ea31004fb293db5a6015aed2abd618340504ee89481d43970a35ff05c3aec2e113ff8b6378ed39415dfec
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,20 @@
|
|
2
2
|
|
3
3
|
## main
|
4
4
|
|
5
|
+
## 2.28.0
|
6
|
+
|
7
|
+
* Include SlotableV2 by default in Base. **Note:** It's no longer necessary to include `ViewComponent::SlotableV2` to use Slots.
|
8
|
+
|
9
|
+
*Joel Hawksley*
|
10
|
+
|
11
|
+
* Prepend Preview routes instead of appending, accounting for cases where host application has catchall route.
|
12
|
+
|
13
|
+
*Joel Hawksley*
|
14
|
+
|
15
|
+
* Fix bug where blocks passed to lambda slots will render incorrectly in certain situations.
|
16
|
+
|
17
|
+
*Blake Williams*
|
18
|
+
|
5
19
|
## 2.27.0
|
6
20
|
|
7
21
|
* Allow customization of the controller used in component tests.
|
data/lib/view_component/base.rb
CHANGED
@@ -61,7 +61,7 @@ module ViewComponent
|
|
61
61
|
"elsif variant.to_sym == :#{variant}\n #{call_method_name(variant)}"
|
62
62
|
end.join("\n")
|
63
63
|
|
64
|
-
component_class.class_eval <<-RUBY
|
64
|
+
component_class.class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
65
65
|
def render_template_for(variant = nil)
|
66
66
|
if variant.nil?
|
67
67
|
call
|
@@ -90,7 +90,7 @@ module ViewComponent
|
|
90
90
|
options = app.config.view_component
|
91
91
|
|
92
92
|
if options.show_previews
|
93
|
-
app.routes.
|
93
|
+
app.routes.prepend do
|
94
94
|
preview_controller = options.preview_controller.sub(/Controller$/, "").underscore
|
95
95
|
|
96
96
|
get options.preview_route, to: "#{preview_controller}#index", as: :preview_view_components, internal: true
|
@@ -49,14 +49,14 @@ module ViewComponent
|
|
49
49
|
|
50
50
|
# If the slot is a collection, define an accesor that defaults to an empty array
|
51
51
|
if collection
|
52
|
-
class_eval <<-RUBY
|
52
|
+
class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
53
53
|
def #{accessor_name}
|
54
54
|
content unless content_evaluated? # ensure content is loaded so slots will be defined
|
55
55
|
#{instance_variable_name} ||= []
|
56
56
|
end
|
57
57
|
RUBY
|
58
58
|
else
|
59
|
-
class_eval <<-RUBY
|
59
|
+
class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
60
60
|
def #{accessor_name}
|
61
61
|
content unless content_evaluated? # ensure content is loaded so slots will be defined
|
62
62
|
#{instance_variable_name} if defined?(#{instance_variable_name})
|
@@ -226,7 +226,11 @@ module ViewComponent
|
|
226
226
|
# Use `bind(self)` to ensure lambda is executed in the context of the
|
227
227
|
# current component. This is necessary to allow the lambda to access helper
|
228
228
|
# methods like `content_tag` as well as parent component state.
|
229
|
-
renderable_value =
|
229
|
+
renderable_value = if block_given?
|
230
|
+
slot_definition[:renderable_function].bind(self).call(*args, **kwargs) { view_context.capture(&block) }
|
231
|
+
else
|
232
|
+
slot_definition[:renderable_function].bind(self).call(*args, **kwargs)
|
233
|
+
end
|
230
234
|
|
231
235
|
# Function calls can return components, so if it's a component handle it specially
|
232
236
|
if renderable_value.respond_to?(:render_in)
|
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.
|
4
|
+
version: 2.28.0
|
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-03-
|
11
|
+
date: 2021-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|