view_component 4.0.0.rc2 → 4.0.0.rc3
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/docs/CHANGELOG.md +14 -0
- data/lib/view_component/base.rb +13 -3
- data/lib/view_component/slot.rb +6 -2
- data/lib/view_component/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9389db3857fccdd96788494eb6992ceca37f1934f9587317b806a992f53a599
|
4
|
+
data.tar.gz: 675ca1e487f5724cc5ac33e397fb9b1f2027347c6ca569223e4e5e772150ad05
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4810cd0a918e52322ef4f0b36b830cbb79cd80b2fce6d9cc680b9b43f5b490e76b412d8504aee3cc577bf6892053ac5ed789fdb14c8c2d71fce582b0011efc95
|
7
|
+
data.tar.gz: b8821ec370dbf668ad03c19b832ccbd8754d0da6a23b131d77f6c4898088214d2d51cb3e0c404ad919a75bf63ea387324f95decf03a497df30f8396650c2cd35
|
data/docs/CHANGELOG.md
CHANGED
@@ -10,6 +10,20 @@ nav_order: 6
|
|
10
10
|
|
11
11
|
## main
|
12
12
|
|
13
|
+
## 4.0.0.rc3
|
14
|
+
|
15
|
+
* Reformat the avatars section to arrange them in a grid.
|
16
|
+
|
17
|
+
*Josh Cohen*
|
18
|
+
|
19
|
+
* Fix bug where relative paths in `translate` didn't work in blocks passed to ViewComponents.
|
20
|
+
|
21
|
+
*Joel Hawksley*
|
22
|
+
|
23
|
+
* Add SerpApi to "Who uses ViewComponent" list.
|
24
|
+
|
25
|
+
*Andy from SerpApi*
|
26
|
+
|
13
27
|
## 4.0.0.rc2
|
14
28
|
|
15
29
|
* Add `around_render` lifecyle method for wrapping component rendering in custom instrumentation, etc.
|
data/lib/view_component/base.rb
CHANGED
@@ -108,7 +108,7 @@ module ViewComponent
|
|
108
108
|
self.class.__vc_compile(raise_errors: true)
|
109
109
|
|
110
110
|
@view_context = view_context
|
111
|
-
old_virtual_path = view_context.instance_variable_get(:@virtual_path)
|
111
|
+
@old_virtual_path = view_context.instance_variable_get(:@virtual_path)
|
112
112
|
self.__vc_original_view_context ||= view_context
|
113
113
|
|
114
114
|
@output_buffer = view_context.output_buffer
|
@@ -166,7 +166,7 @@ module ViewComponent
|
|
166
166
|
""
|
167
167
|
end
|
168
168
|
ensure
|
169
|
-
view_context.instance_variable_set(:@virtual_path, old_virtual_path)
|
169
|
+
view_context.instance_variable_set(:@virtual_path, @old_virtual_path)
|
170
170
|
@current_template = old_current_template
|
171
171
|
end
|
172
172
|
|
@@ -341,7 +341,9 @@ module ViewComponent
|
|
341
341
|
|
342
342
|
@__vc_content =
|
343
343
|
if __vc_render_in_block_provided?
|
344
|
-
|
344
|
+
with_original_virtual_path do
|
345
|
+
view_context.capture(self, &@__vc_render_in_block)
|
346
|
+
end
|
345
347
|
elsif __vc_content_set_by_with_content_defined?
|
346
348
|
@__vc_content_set_by_with_content
|
347
349
|
end
|
@@ -358,6 +360,14 @@ module ViewComponent
|
|
358
360
|
self.class.__vc_response_format
|
359
361
|
end
|
360
362
|
|
363
|
+
# @private
|
364
|
+
def with_original_virtual_path
|
365
|
+
@view_context.instance_variable_set(:@virtual_path, @old_virtual_path)
|
366
|
+
yield
|
367
|
+
ensure
|
368
|
+
@view_context.instance_variable_set(:@virtual_path, virtual_path)
|
369
|
+
end
|
370
|
+
|
361
371
|
private
|
362
372
|
|
363
373
|
attr_reader :view_context
|
data/lib/view_component/slot.rb
CHANGED
@@ -58,7 +58,9 @@ module ViewComponent
|
|
58
58
|
if defined?(@__vc_content_block)
|
59
59
|
# render_in is faster than `parent.render`
|
60
60
|
@__vc_component_instance.render_in(view_context) do |*args|
|
61
|
-
@
|
61
|
+
@parent.with_original_virtual_path do
|
62
|
+
@__vc_content_block.call(*args)
|
63
|
+
end
|
62
64
|
end
|
63
65
|
else
|
64
66
|
@__vc_component_instance.render_in(view_context)
|
@@ -66,7 +68,9 @@ module ViewComponent
|
|
66
68
|
elsif defined?(@__vc_content)
|
67
69
|
@__vc_content
|
68
70
|
elsif defined?(@__vc_content_block)
|
69
|
-
|
71
|
+
@parent.with_original_virtual_path do
|
72
|
+
view_context.capture(&@__vc_content_block)
|
73
|
+
end
|
70
74
|
elsif defined?(@__vc_content_set_by_with_content)
|
71
75
|
@__vc_content_set_by_with_content
|
72
76
|
end
|