view_component 4.0.0.rc1 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7a112fdf735637f91b77151d96244fac83f0d78141df7a2a0ff8f2d72d0df2d0
4
- data.tar.gz: 39c33408d7f256dc0da92edb17ca18460d776e6f1be89ba63d28e3ea102f8ba9
3
+ metadata.gz: c9389db3857fccdd96788494eb6992ceca37f1934f9587317b806a992f53a599
4
+ data.tar.gz: 675ca1e487f5724cc5ac33e397fb9b1f2027347c6ca569223e4e5e772150ad05
5
5
  SHA512:
6
- metadata.gz: b4c4f99335d6c2be623f1bd167e3d27567a7093acb388be1c245a6652423e4cc0ee8a16946da2d5ca9d35dd0283fecb1647888def129ec6fb75b82f427379558
7
- data.tar.gz: 0ccb738fb45917ee49886ad2b1359a9bd3d98bf86d7e25f81422cffa5390514fe45d254a1e2d5900b6aa5649f428fa512d6a26c6d486d67546da8729dcc0d26f
6
+ metadata.gz: 4810cd0a918e52322ef4f0b36b830cbb79cd80b2fce6d9cc680b9b43f5b490e76b412d8504aee3cc577bf6892053ac5ed789fdb14c8c2d71fce582b0011efc95
7
+ data.tar.gz: b8821ec370dbf668ad03c19b832ccbd8754d0da6a23b131d77f6c4898088214d2d51cb3e0c404ad919a75bf63ea387324f95decf03a497df30f8396650c2cd35
data/docs/CHANGELOG.md CHANGED
@@ -10,6 +10,26 @@ 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
+
27
+ ## 4.0.0.rc2
28
+
29
+ * Add `around_render` lifecyle method for wrapping component rendering in custom instrumentation, etc.
30
+
31
+ *Joel Hawksley*, *Blake Williams*
32
+
13
33
  ## 4.0.0.rc1
14
34
 
15
35
  Almost six years after releasing [v1.0.0](https://github.com/ViewComponent/view_component/releases/tag/v1.0.0), we're proud to ship the first release candidate of ViewComponent 4. This release marks a shift towards a Long Term Support model for the project, having reached significant feature maturity. While contributions are always welcome, we're unlikely to accept further breaking changes or major feature additions.
@@ -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
@@ -143,7 +143,10 @@ module ViewComponent
143
143
  @output_buffer.with_buffer do
144
144
  @view_context.instance_variable_set(:@virtual_path, virtual_path)
145
145
 
146
- rendered_template = render_template_for(@__vc_requested_details).to_s
146
+ rendered_template =
147
+ around_render do
148
+ render_template_for(@__vc_requested_details).to_s
149
+ end
147
150
 
148
151
  # Avoid allocating new string when output_preamble and output_postamble are blank
149
152
  value = if output_preamble.blank? && output_postamble.blank?
@@ -163,7 +166,7 @@ module ViewComponent
163
166
  ""
164
167
  end
165
168
  ensure
166
- view_context.instance_variable_set(:@virtual_path, old_virtual_path)
169
+ view_context.instance_variable_set(:@virtual_path, @old_virtual_path)
167
170
  @current_template = old_current_template
168
171
  end
169
172
 
@@ -228,6 +231,14 @@ module ViewComponent
228
231
  # noop
229
232
  end
230
233
 
234
+ # Called around rendering the component. Override to wrap the rendering of a
235
+ # component in custom instrumentation, etc.
236
+ #
237
+ # @return [void]
238
+ def around_render
239
+ yield
240
+ end
241
+
231
242
  # Override to determine whether the ViewComponent should render.
232
243
  #
233
244
  # @return [Boolean]
@@ -330,7 +341,9 @@ module ViewComponent
330
341
 
331
342
  @__vc_content =
332
343
  if __vc_render_in_block_provided?
333
- view_context.capture(self, &@__vc_render_in_block)
344
+ with_original_virtual_path do
345
+ view_context.capture(self, &@__vc_render_in_block)
346
+ end
334
347
  elsif __vc_content_set_by_with_content_defined?
335
348
  @__vc_content_set_by_with_content
336
349
  end
@@ -347,6 +360,14 @@ module ViewComponent
347
360
  self.class.__vc_response_format
348
361
  end
349
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
+
350
371
  private
351
372
 
352
373
  attr_reader :view_context
@@ -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
- @__vc_content_block.call(*args)
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
- view_context.capture(&@__vc_content_block)
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
@@ -5,7 +5,7 @@ module ViewComponent
5
5
  MAJOR = 4
6
6
  MINOR = 0
7
7
  PATCH = 0
8
- PRE = "rc1"
8
+ PRE = "rc3"
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join(".")
11
11
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: view_component
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0.rc1
4
+ version: 4.0.0.rc3
5
5
  platform: ruby
6
6
  authors:
7
7
  - ViewComponent Team