view_component 3.23.2 → 4.12.0

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.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/concerns/view_component/preview_actions.rb +11 -14
  3. data/app/controllers/view_components_system_test_controller.rb +25 -19
  4. data/app/views/test_mailer/test_asset_email.html.erb +1 -0
  5. data/app/views/test_mailer/test_url_email.html.erb +1 -0
  6. data/app/views/view_components/preview.html.erb +1 -9
  7. data/docs/CHANGELOG.md +612 -108
  8. data/lib/{rails/generators → generators/view_component}/abstract_generator.rb +2 -2
  9. data/lib/{rails/generators → generators/view_component}/component/component_generator.rb +17 -4
  10. data/lib/{rails/generators → generators/view_component}/component/templates/component.rb.tt +6 -1
  11. data/lib/{rails/generators/erb/component_generator.rb → generators/view_component/erb/erb_generator.rb} +4 -3
  12. data/lib/{rails/generators/haml/component_generator.rb → generators/view_component/haml/haml_generator.rb} +3 -3
  13. data/lib/{rails/generators/locale/component_generator.rb → generators/view_component/locale/locale_generator.rb} +3 -3
  14. data/lib/{rails/generators/preview/component_generator.rb → generators/view_component/preview/preview_generator.rb} +3 -3
  15. data/lib/{rails/generators/rspec/component_generator.rb → generators/view_component/rspec/rspec_generator.rb} +3 -3
  16. data/lib/{rails/generators/slim/component_generator.rb → generators/view_component/slim/slim_generator.rb} +3 -3
  17. data/lib/{rails/generators/stimulus/component_generator.rb → generators/view_component/stimulus/stimulus_generator.rb} +3 -3
  18. data/lib/generators/view_component/tailwindcss/tailwindcss_generator.rb +11 -0
  19. data/lib/{rails/generators/test_unit/component_generator.rb → generators/view_component/test_unit/test_unit_generator.rb} +2 -2
  20. data/lib/view_component/base.rb +252 -163
  21. data/lib/view_component/collection.rb +33 -35
  22. data/lib/view_component/compiler.rb +55 -80
  23. data/lib/view_component/config.rb +55 -85
  24. data/lib/view_component/configurable.rb +19 -3
  25. data/lib/view_component/deprecation.rb +1 -1
  26. data/lib/view_component/engine.rb +46 -106
  27. data/lib/view_component/errors.rb +16 -34
  28. data/lib/view_component/inline_template.rb +4 -4
  29. data/lib/view_component/instrumentation.rb +21 -14
  30. data/lib/view_component/preview.rb +7 -12
  31. data/lib/view_component/request_details.rb +30 -0
  32. data/lib/view_component/slot.rb +7 -15
  33. data/lib/view_component/slotable.rb +94 -80
  34. data/lib/view_component/system_spec_helpers.rb +11 -0
  35. data/lib/view_component/system_test_helpers.rb +2 -2
  36. data/lib/view_component/template.rb +159 -83
  37. data/lib/view_component/test_helpers.rb +67 -50
  38. data/lib/view_component/translatable.rb +33 -32
  39. data/lib/view_component/version.rb +3 -3
  40. data/lib/view_component.rb +9 -6
  41. metadata +36 -556
  42. data/app/assets/vendor/prism.css +0 -4
  43. data/app/assets/vendor/prism.min.js +0 -12
  44. data/app/helpers/preview_helper.rb +0 -85
  45. data/app/views/view_components/_preview_source.html.erb +0 -17
  46. data/lib/rails/generators/tailwindcss/component_generator.rb +0 -11
  47. data/lib/view_component/capture_compatibility.rb +0 -44
  48. data/lib/view_component/component_error.rb +0 -6
  49. data/lib/view_component/rails/tasks/view_component.rake +0 -20
  50. data/lib/view_component/render_component_helper.rb +0 -10
  51. data/lib/view_component/render_component_to_string_helper.rb +0 -9
  52. data/lib/view_component/render_monkey_patch.rb +0 -13
  53. data/lib/view_component/render_to_string_monkey_patch.rb +0 -13
  54. data/lib/view_component/rendering_component_helper.rb +0 -9
  55. data/lib/view_component/rendering_monkey_patch.rb +0 -13
  56. data/lib/view_component/slotable_default.rb +0 -20
  57. data/lib/view_component/use_helpers.rb +0 -42
  58. /data/lib/{rails/generators → generators/view_component}/erb/templates/component.html.erb.tt +0 -0
  59. /data/lib/{rails/generators → generators/view_component}/haml/templates/component.html.haml.tt +0 -0
  60. /data/lib/{rails/generators → generators/view_component}/preview/templates/component_preview.rb.tt +0 -0
  61. /data/lib/{rails/generators → generators/view_component}/rspec/templates/component_spec.rb.tt +0 -0
  62. /data/lib/{rails/generators → generators/view_component}/slim/templates/component.html.slim.tt +0 -0
  63. /data/lib/{rails/generators → generators/view_component}/stimulus/templates/component_controller.js.tt +0 -0
  64. /data/lib/{rails/generators → generators/view_component}/stimulus/templates/component_controller.ts.tt +0 -0
  65. /data/lib/{rails/generators → generators/view_component}/tailwindcss/templates/component.html.erb.tt +0 -0
  66. /data/lib/{rails/generators → generators/view_component}/test_unit/templates/component_test.rb.tt +0 -0
data/docs/CHANGELOG.md CHANGED
@@ -10,6 +10,618 @@ nav_order: 6
10
10
 
11
11
  ## main
12
12
 
13
+ ## 4.12.0
14
+
15
+ * Fix stale render context on reused component instances. A `ViewComponent::Base` instance memoized its controller, helpers, request, view context, lookup context, view flow, and requested format details on first render via `||=`. Rendering the same instance a second time (intentionally or via aliasing) reused that stale context, which could leak data across requests, sessions, or users. `#render_in` now resets these ivars on every call so each render derives its context from the current view.
16
+
17
+ *Joel Hawksley*
18
+
19
+ * Fix HTML-safety bypass in `around_render`. `ViewComponent::Base#around_render` could return HTML-unsafe strings that bypassed the escaping applied to normal `#call` return values, creating an XSS risk. The vulnerability was amplified in `ViewComponent::Collection#render_in`, which joined per-item results and unconditionally marked the output `html_safe`. HTML-unsafe strings returned from `around_render` are now escaped (with a warning) and `Collection#render_in` now uses `safe_join` so unsafe per-item output is escaped instead of laundered into a `SafeBuffer`.
20
+
21
+ *Joel Hawksley*
22
+
23
+ ## 4.11.0
24
+
25
+ * Update `render_in` signature to accept `**_` for compatibility with Rails [#50623](https://github.com/rails/rails/pull/50623).
26
+
27
+ *Joel Hawksley*
28
+
29
+ * Fix translation scope resolution in nested lambda-backed slots. Relative `t(".key")` calls inside lambda-backed slots were resolving against an intermediate component's scope instead of the original partial's scope where the block was defined.
30
+
31
+ *Artin Boghosian*
32
+
33
+ ## 4.10.0
34
+
35
+ * Fix `NameError: uninitialized constant ViewComponent::SystemTestControllerNefariousPathError` when booting in the test environment with `eager_load = true`.
36
+
37
+ *Joel Hawksley*
38
+
39
+ * Fix yielded content rendered at wrong location when using form helpers.
40
+
41
+ *Joel Hawksley*, *Markus*
42
+
43
+ ## 4.9.0
44
+
45
+ * Fix path traversal vulnerability in `ViewComponentsSystemTestController` where sibling directories sharing a string prefix with the allowed temp directory could bypass the path containment check. The `start_with?` check has been replaced with a separator-aware prefix check, and nefarious path errors now return a 404 instead of an unhandled exception.
46
+
47
+ *Joel Hawksley*
48
+
49
+ * Fix preview route vulnerability where inherited methods on `ViewComponent::Preview` (such as `render_with_template`) could be invoked via the preview URL, allowing arbitrary internal Rails templates to be rendered with attacker-controlled locals and request parameters. `render_args` now raises `AbstractController::ActionNotFound` for any example not explicitly declared on the preview subclass.
50
+
51
+ *Joel Hawksley*
52
+
53
+ * Add `yard-lint` to CI.
54
+
55
+ *Joel Hawksley*
56
+
57
+ ## 4.8.0
58
+
59
+ * Add `compile.view_component` ActiveSupport::Notifications event for eager compilation at boot time.
60
+
61
+ *Joel Hawksley*, *GitHub Copilot*
62
+
63
+ ## 4.7.0
64
+
65
+ * Fix stale content cache when slots are accessed before `render_in`.
66
+
67
+ *Jared Armstrong*
68
+
69
+ * Add rubocop-view_component to resources.
70
+
71
+ *Andy Waite*
72
+
73
+ * Fix bug where inheritance of components with formatless templates improperly raised a NoMethodError.
74
+
75
+ *GitHub Copilot*, *Joel Hawksley*, *Cameron Dutro*
76
+
77
+ ## 4.6.0
78
+
79
+ * Add `view_identifier` to the `render.view_component` instrumentation event payload, containing the path to the component's template file (e.g. `app/components/my_component.html.erb`). For components using inline render methods, `view_identifier` will be `nil`.
80
+
81
+ *GitHub Copilot*
82
+
83
+ * Replace deprecated `require_dependency` with `require` in preview loading.
84
+
85
+ *GitHub Copilot*
86
+
87
+ * Return `html_safe` empty string from `render_in` when `render?` is false.
88
+
89
+ *GitHub Copilot*
90
+
91
+ ## 4.5.0
92
+
93
+ * Fix initialization ordering issue causing missing asset errors in Sprockets.
94
+
95
+ *Cameron Dutro*
96
+
97
+ ## 4.4.0
98
+
99
+ * Fix segfaults when Ruby coverage is enabled.
100
+
101
+ *George Holborn*, *Joel Hawksley*
102
+
103
+ * Add `protocol` parameter to `with_request_url` test helper to enable testing with HTTPS protocol.
104
+
105
+ *Joel Hawksley*
106
+
107
+ ## 4.3.0
108
+
109
+ * Fix load order issues for 3rd-party template handlers.
110
+
111
+ *Cameron Dutro*
112
+
113
+ * Fix segfault when Ruby coverage is enabled with Rails 8.1 ERB templates.
114
+
115
+ *George Holborn*
116
+
117
+ * Automatically merge dependabot PRs.
118
+
119
+ *Joel Hawksley*
120
+
121
+ * Use Ruby 4.0.0 in CI and dev.
122
+
123
+ *Joel Hawksley*
124
+
125
+ ## 4.2.0
126
+
127
+ * Fix translation scope resolution in deeply nested component blocks (3+ levels). Translations called inside deeply nested slot blocks using `renders_many`/`renders_one` were incorrectly resolving to an intermediate component's scope instead of the partial's scope where the block was defined. The fix captures the virtual path at block definition time and restores it during block execution, ensuring translations always resolve relative to where the block was created regardless of nesting depth.
128
+
129
+ *Nathaniel Watts*
130
+
131
+ * Allow `render_inline` with Nokogiri::HTML5 to parse more arbitrary content including bare table content otherwise illegal fragments like `<td>`.
132
+
133
+ *Jonathan Rochkind*
134
+
135
+ * Remove known issue from docs as ActiveScaffold is [now compatible](https://github.com/activescaffold/active_scaffold/pull/743) with ViewComponent.
136
+
137
+ *David Löwenfels*
138
+
139
+ * Add test to document the current behavior for resolving relative translation keys within partial blocks. When rendering a partial, relative translation keys are resolved relative to the partial's own path rather than the caller’s path. This test ensures that this behavior remains consistent.
140
+
141
+ *Oussama Hilal*
142
+
143
+ * Allow I18n calls in `render?`.
144
+
145
+ *23tux*
146
+
147
+ * ViewComponent now works without `rails` and `railties` gems loaded, enabling compatibility with Bridgetown 2.0.
148
+
149
+ *Tom Lord*
150
+
151
+ * Capture partial block in the component's context, allowing access to the component instance inside the block.
152
+
153
+ *23tux*
154
+
155
+ * Add `after_compile` class method hook to enable extensions to run logic after component compilation.
156
+
157
+ *Jose Solás*
158
+
159
+ * Fix outdated reference to preview layout configuration in docs.
160
+
161
+ *Lucas Geron*
162
+
163
+ * Allow ruby-head CI job to fail without failing workflow.
164
+
165
+ *Hakan Ensari*
166
+
167
+ * Fix bug where error line numbers were incorrect in Rails 8.1.
168
+
169
+ *Joel Hawksley*
170
+
171
+ * Remove `< 8.2` upper bound for `activesupport` and `actionview` dependencies.
172
+
173
+ *Hans Lemuet*
174
+
175
+ * Test compatibility with Herb/ReActionView.
176
+
177
+ *Joel Hawksley*
178
+
179
+ * Remove Who Uses ViewComponent section from docs.
180
+
181
+ *Joel Hawksley*
182
+
183
+ ## 4.1.1
184
+
185
+ * Resolve deprecation warning for `ActiveSupport::Configurable`.
186
+
187
+ *Simon Fish*
188
+
189
+ * Make `ViewComponent::VERSION` accessible to other gems by default.
190
+
191
+ *Hans Lemuet*
192
+
193
+ ## 4.1.0
194
+
195
+ * Add Rails 8.1 support.
196
+
197
+ *Hans Lemuet*
198
+
199
+ * Declare `actionview` as a `view_component` gem dependency.
200
+
201
+ *Michal Cichra*
202
+
203
+ ## 4.0.2
204
+
205
+ * Share the view context in tests to prevent out-of-order rendering issues for certain advanced use-cases, eg. testing instances of Rails' `FormBuilder`.
206
+ * Fix double rendering issue for partials that yield.
207
+
208
+ *Cameron Dutro*
209
+
210
+ ## 4.0.1
211
+
212
+ * Setup Trusted Publishing to RubyGems to improve software supply chain safety.
213
+
214
+ *Hans Lemuet*
215
+
216
+ * Conditionally add the `ViewComponent::Base#format` method back for Rails 7.1 only.
217
+ * Compute and check lockfiles into source control.
218
+ * Constrain Rails versions in gemfiles to only allow the patch version to vary, eg. `~> 7.1.0` instead of `~> 7.1`.
219
+
220
+ *Cameron Dutro*
221
+
222
+ ## 4.0.0
223
+
224
+ Two years after releasing [3.0.0](https://github.com/ViewComponent/view_component/releases/tag/v3.0.0) and almost six years since [1.0.0](https://github.com/ViewComponent/view_component/releases/tag/v1.0.0), we're proud to ship 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.
225
+
226
+ Please report any issues at [https://github.com/ViewComponent/view_component/issues](https://github.com/ViewComponent/view_component/issues).
227
+
228
+ ### Breaking changes (production)
229
+
230
+ * Remove dependency on `ActionView::Base`, eliminating the need for capture compatibility patch. In some edge cases, this change may require switching to use the `helpers.` proxy.
231
+ * Require [non-EOL](https://endoflife.date/rails) Rails (`>= 7.1.0`) and Ruby (`>= 3.2.0`).
232
+ * Remove `render_component` and `render` monkey patch configured with `render_monkey_patch_enabled`.
233
+ * Remove deprecated `use_helper(s)`. Use `include MyHelper` or `helpers.` proxy instead.
234
+ * Support compatibility with `Dry::Initializer`. As a result, `EmptyOrInvalidInitializerError` will no longer be raised.
235
+ * Remove default initializer from `ViewComponent::Base`. Previously, `ViewComponent::Base` defined a catch-all initializer that allowed components without an initializer defined to be passed arbitrary arguments.
236
+ * Remove `use_deprecated_instrumentation_name` configuration option. Events will always use `render.view_component` name.
237
+ * Remove unnecessary `#format` methods that returned `nil`.
238
+ * Remove support for variant names containing `.` to be consistent with Rails.
239
+ * Rename internal methods to have `__vc_` prefix if they shouldn't be used by consumers. Make internal constants private. Make `Collection#components`, `Slotable#register_polymorphic_slot` private. Remove unused `ComponentError` class.
240
+ * Use ActionView's `lookup_context` for picking templates instead of the request format.
241
+
242
+ 3.15 added support for using templates that match the request format, that is if `/resource.csv` is requested then
243
+ ViewComponents would pick `_component.csv.erb` over `_component.html.erb`.
244
+
245
+ With this release, the request format is no longer considered and instead ViewComponent will use the Rails logic for picking the most appropriate template type, that is the csv template will be used if it matches the `Accept` header or because the controller uses a `respond_to` block to pick the response format.
246
+
247
+ ### Breaking changes (dev/test)
248
+
249
+ * Remove `config.view_component.test_controller` in favor of `vc_test_controller_class` test helper method.
250
+ * `config.view_component.component_parent_class` is now `config.view_component.generate.parent_class`, moving the generator-specific option to the generator configuration namespace.
251
+ * `config.view_component.view_component_path` is now `config.view_component.generate.path`, as components have long since been able to exist in any directory.
252
+ * Move previews-related configuration (`enabled`, `route`, `paths`, `default_layout`, `controller`) to under `previews` namespace.
253
+ * `--inline` generator option now generates inline template. Use `--call` to generate `#call` method.
254
+ * Remove broken integration with `rails stats` that ignored components outside of `app/components`.
255
+ * Remove `preview_source` functionality. Consider using [Lookbook](https://lookbook.build/) instead.
256
+ * Use `Nokogiri::HTML5` instead of `Nokogiri::HTML4` for test helpers.
257
+ * Move generators to a ViewComponent namespace.
258
+
259
+ Before, ViewComponent generators pollute the generator namespace with a bunch of top level items, and claim the generic "component" name.
260
+
261
+ Now, generators live in a "view_component" module/namespace, so what was before `rails g
262
+ component` is now `rails g view_component:component`.
263
+
264
+ ### New features
265
+
266
+ * Add `SystemSpecHelpers` for use with RSpec.
267
+ * Add support for including `Turbo::StreamsHelper`.
268
+ * Add template annotations for components with `def call`.
269
+ * Graduate `SlotableDefault` to be included by default.
270
+ * Add `#current_template` accessor and `Template#path` for diagnostic usage.
271
+ * Reduce string allocations during compilation.
272
+ * Add `around_render` lifecyle method for wrapping component rendering in custom instrumentation, etc.
273
+
274
+ ### Bug fixes
275
+
276
+ * Fix bug where virtual path wasn't reset, breaking translations outside of components.
277
+ * Fix bug where `config.view_component.previews.enabled` didn't function properly in production environments.
278
+ * Fix bug in `SlotableDefault` where default couldn't be overridden when content was passed as a block.
279
+ * Fix bug where request-aware helpers didn't work outside of the request context.
280
+ * `ViewComponentsSystemTestController` shouldn't be useable outside of test environment
281
+
282
+ ### Non-functional changes
283
+
284
+ * Remove unnecessary usage of `ruby2_keywords`.
285
+ * Remove unnecessary `respond_to` checks.
286
+ * Require MFA when publishing to RubyGems.
287
+ * Clean up project dependencies, relaxing versions of development gems.
288
+ * Add test case for absolute URL path helpers in mailers.
289
+ * Update documentation on performance to reflect more representative benchmark showing 2-3x speed increase over partials.
290
+ * Add documentation note about instrumentation negatively affecting performance.
291
+ * Remove unnecessary ENABLE_RELOADING test suite flag.
292
+ * `config.view_component.previews.default_layout` should default to nil.
293
+ * Add test coverage for uncovered code.
294
+ * Test against `turbo-rails` `v2` and `rspec-rails` `v7`.
295
+
296
+ ## 4.0.0.rc5
297
+
298
+ * Revert change setting `#format`. In GitHub's codebase, the change led to hard-to-detect failures. For example, components rendered from controllers included layouts when they didn't before. In other cases, the response `content_type` changed, breaking downstream consumers. For cases where a specific content type is needed, use:
299
+
300
+ ```ruby
301
+ respond_to do |f|
302
+ f.html_fragment do
303
+ render(MyComponent.new)
304
+ end
305
+ end
306
+ ```
307
+
308
+ *Joel Hawksley*
309
+
310
+ ## 4.0.0.rc4
311
+
312
+ * Fix issue where generators were not included in published gem.
313
+
314
+ *Jean-Louis Giordano*
315
+
316
+ ## 4.0.0.rc3
317
+
318
+ * Reformat the avatars section to arrange them in a grid.
319
+
320
+ *Josh Cohen*
321
+
322
+ * Fix bug where relative paths in `translate` didn't work in blocks passed to ViewComponents.
323
+
324
+ *Joel Hawksley*
325
+
326
+ * Add SerpApi to "Who uses ViewComponent" list.
327
+
328
+ *Andy from SerpApi*
329
+
330
+ ## 4.0.0.rc2
331
+
332
+ * Add `around_render` lifecyle method for wrapping component rendering in custom instrumentation, etc.
333
+
334
+ *Joel Hawksley*, *Blake Williams*
335
+
336
+ ## 4.0.0.rc1
337
+
338
+ 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.
339
+
340
+ Please report any issues at [https://github.com/ViewComponent/view_component/issues](https://github.com/ViewComponent/view_component/issues).
341
+
342
+ ### 4.0.0.rc1 Breaking changes (production)
343
+
344
+ * Remove dependency on `ActionView::Base`, eliminating the need for capture compatibility patch. In some edge cases, this change may require switching to use the `helpers.` proxy.
345
+ * Require [non-EOL](https://endoflife.date/rails) Rails (`>= 7.1.0`) and Ruby (`>= 3.2.0`).
346
+ * Remove `render_component` and `render` monkey patch configured with `render_monkey_patch_enabled`.
347
+ * Remove deprecated `use_helper(s)`. Use `include MyHelper` or `helpers.` proxy instead.
348
+ * Support compatibility with `Dry::Initializer`. As a result, `EmptyOrInvalidInitializerError` will no longer be raised.
349
+ * Remove default initializer from `ViewComponent::Base`. Previously, `ViewComponent::Base` defined a catch-all initializer that allowed components without an initializer defined to be passed arbitrary arguments.
350
+ * Remove `use_deprecated_instrumentation_name` configuration option. Events will always use `render.view_component` name.
351
+ * Remove unnecessary `#format` methods that returned `nil`.
352
+ * Remove support for variant names containing `.` to be consistent with Rails.
353
+ * Rename internal methods to have `__vc_` prefix if they shouldn't be used by consumers. Make internal constants private. Make `Collection#components`, `Slotable#register_polymorphic_slot` private. Remove unused `ComponentError` class.
354
+ * Use ActionView's `lookup_context` for picking templates instead of the request format.
355
+
356
+ 3.15 added support for using templates that match the request format, that is if `/resource.csv` is requested then
357
+ ViewComponents would pick `_component.csv.erb` over `_component.html.erb`.
358
+
359
+ With this release, the request format is no longer considered and instead ViewComponent will use the Rails logic for picking the most appropriate template type, that is the csv template will be used if it matches the `Accept` header or because the controller uses a `respond_to` block to pick the response format.
360
+
361
+ ### 4.0.0.rc1 Breaking changes (dev/test)
362
+
363
+ * Rename `config.generate.component_parent_class` to `config.generate.parent_class`.
364
+ * Remove `config.test_controller` in favor of `vc_test_controller_class` test helper method.
365
+ * `config.component_parent_class` is now `config.generate.component_parent_class`, moving the generator-specific option to the generator configuration namespace.
366
+ * Move previews-related configuration (`enabled`, `route`, `paths`, `default_layout`, `controller`) to under `previews` namespace.
367
+ * `config.view_component_path` is now `config.generate.path`, as components have long since been able to exist in any directory.
368
+ * `--inline` generator option now generates inline template. Use `--call` to generate `#call` method.
369
+ * Remove broken integration with `rails stats` that ignored components outside of `app/components`.
370
+ * Remove `preview_source` functionality. Consider using [Lookbook](https://lookbook.build/) instead.
371
+ * Use `Nokogiri::HTML5` instead of `Nokogiri::HTML4` for test helpers.
372
+ * Move generators to a ViewComponent namespace.
373
+
374
+ Before, ViewComponent generators pollute the generator namespace with a bunch of top level items, and claim the generic "component" name.
375
+
376
+ Now, generators live in a "view_component" module/namespace, so what was before `rails g
377
+ component` is now `rails g view_component:component`.
378
+
379
+ ### 4.0.0.rc1 New features
380
+
381
+ * Add `SystemSpecHelpers` for use with RSpec.
382
+ * Add support for including `Turbo::StreamsHelper`.
383
+ * Add template annotations for components with `def call`.
384
+ * Graduate `SlotableDefault` to be included by default.
385
+ * Add `#current_template` accessor and `Template#path` for diagnostic usage.
386
+ * Reduce string allocations during compilation.
387
+
388
+ ### 4.0.0.rc1 Bug fixes
389
+
390
+ * Fix bug where virtual path wasn't reset, breaking translations outside of components.
391
+ * Fix bug where `config.previews.enabled` didn't function properly in production environments.
392
+ * Fix bug where response format wasn't set, which caused issues with Turbo Frames.
393
+ * Fix bug in `SlotableDefault` where default couldn't be overridden when content was passed as a block.
394
+ * Fix bug where request-aware helpers didn't work outside of the request context.
395
+ * `ViewComponentsSystemTestController` shouldn't be useable outside of test environment
396
+
397
+ ### 4.0.0.rc1 Non-functional changes
398
+
399
+ * Remove unnecessary usage of `ruby2_keywords`.
400
+ * Remove unnecessary `respond_to` checks.
401
+ * Require MFA when publishing to RubyGems.
402
+ * Clean up project dependencies, relaxing versions of development gems.
403
+ * Add test case for absolute URL path helpers in mailers.
404
+ * Update documentation on performance to reflect more representative benchmark showing 2-3x speed increase over partials.
405
+ * Add documentation note about instrumentation negatively affecting performance.
406
+ * Remove unnecessary ENABLE_RELOADING test suite flag.
407
+ * `config.previews.default_layout` should default to nil.
408
+ * Add test coverage for uncovered code.
409
+ * Test against `turbo-rails` `v2` and `rspec-rails` `v7`.
410
+
411
+ ## 4.0.0.alpha7
412
+
413
+ * BREAKING: Remove deprecated `use_helper(s)`. Use `include MyHelper` or `helpers.` proxy instead.
414
+
415
+ *Joel Hawksley*
416
+
417
+ * BREAKING: Support compatibility with `Dry::Initializer`. As a result, `EmptyOrInvalidInitializerError` will no longer be raised.
418
+
419
+ *Joel Hawksley*
420
+
421
+ * BREAKING: Rename `config.generate.component_parent_class` to `config.generate.parent_class`.
422
+
423
+ *Joel Hawksley*
424
+
425
+ * Fix bug where `config.previews.enabled` didn't function properly in production environments.
426
+
427
+ *Joel Hawksley*
428
+
429
+ * `config.previews.default_layout` should default to nil.
430
+
431
+ *Joel Hawksley*
432
+
433
+ * Add test case for absolute URL path helpers in mailers.
434
+
435
+ *Joel Hawksley*
436
+
437
+ * Fix bug where response format wasn't set, which caused issues with Turbo Frames.
438
+
439
+ *Joel Hawksley*
440
+
441
+ ## 4.0.0.alpha6
442
+
443
+ * BREAKING: Remove `config.test_controller` in favor of `vc_test_controller_class` test helper method.
444
+
445
+ *Joel Hawksley*
446
+
447
+ * BREAKING: `config.component_parent_class` is now `config.generate.component_parent_class`, moving the generator-specific option to the generator configuration namespace.
448
+
449
+ *Joel Hawksley*
450
+
451
+ * BREAKING: Move previews-related configuration (`enabled`, `route`, `paths`, `default_layout`, `controller`) to under `previews` namespace.
452
+
453
+ *Joel Hawksley*
454
+
455
+ * Add template annotations for components with `def call`.
456
+
457
+ *Joel Hawksley*
458
+
459
+ * Add support for including Turbo::StreamsHelper.
460
+
461
+ *Stephen Nelson*
462
+
463
+ * Update documentation on performance to reflect more representative benchmark showing 2-3x speed increase over partials.
464
+
465
+ *Joel Hawksley*
466
+
467
+ * Add documentation note about instrumentation negatively affecting performance.
468
+
469
+ *Joel Hawksley*
470
+
471
+ * Revert object shapes optimization due to lack of evidence of improvement.
472
+
473
+ *Joel Hawksley*
474
+
475
+ ## 4.0.0.alpha5
476
+
477
+ * BREAKING: `config.view_component_path` is now `config.generate.path`, as components have long since been able to exist in any directory.
478
+
479
+ *Joel Hawksley*
480
+
481
+ * BREAKING: Remove broken integration with `rails stats` that ignored components outside of `app/components`.
482
+
483
+ *Joel Hawksley*
484
+
485
+ ## 4.0.0.alpha4
486
+
487
+ * BREAKING: Remove default initializer from `ViewComponent::Base`. Previously, `ViewComponent::Base` defined a catch-all initializer that allowed components without an initializer defined to be passed arbitrary arguments.
488
+
489
+ *Joel Hawksley*
490
+
491
+ * Graduate `SlotableDefault` to be included by default.
492
+
493
+ *Joel Hawksley*
494
+
495
+ * Fix bug in `SlotableDefault` where default couldn't be overridden when content was passed as a block.
496
+
497
+ *Bill Watts*, *Joel Hawksley*
498
+
499
+ ## 4.0.0.alpha3
500
+
501
+ * BREAKING: Remove dependency on `ActionView::Base`, eliminating the need for capture compatibility patch.
502
+
503
+ *Cameron Dutro*
504
+
505
+ ## 4.0.0.alpha2
506
+
507
+ * Add `#current_template` accessor and `Template#path` for diagnostic usage.
508
+
509
+ *Joel Hawksley*
510
+
511
+ ## 4.0.0.alpha1
512
+
513
+ Almost six years after releasing [v1.0.0](https://github.com/ViewComponent/view_component/releases/tag/v1.0.0), we're proud to ship 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.
514
+
515
+ This release makes the following breaking changes:
516
+
517
+ * BREAKING: `--inline` generator option now generates inline template. Use `--call` to generate `#call` method.
518
+
519
+ *Joel Hawksley*
520
+
521
+ * BREAKING: Remove `use_deprecated_instrumentation_name` configuration option. Events will always use `render.view_component` name.
522
+
523
+ *Joel Hawksley*
524
+
525
+ * BREAKING: Remove `preview_source` functionality. Consider using [Lookbook](https://lookbook.build/) instead.
526
+
527
+ *Joel Hawksley*
528
+
529
+ * BREAKING: Use `Nokogiri::HTML5` instead of `Nokogiri::HTML4` for test helpers.
530
+
531
+ *Noah Silvera*, *Joel Hawksley*
532
+
533
+ * BREAKING: Move generators to a ViewComponent namespace.
534
+
535
+ Before, ViewComponent generators pollute the generator namespace with a bunch of top level items, and claim the generic "component" name.
536
+
537
+ Now, generators live in a "view_component" module/namespace, so what was before `rails g
538
+ component` is now `rails g view_component:component`.
539
+
540
+ *Paul Sadauskas*
541
+
542
+ * BREAKING: Require [non-EOL](https://endoflife.date/rails) Rails (`>= 7.1.0`).
543
+
544
+ *Joel Hawksley*
545
+
546
+ * BREAKING: Require [non-EOL](https://www.ruby-lang.org/en/downloads/branches/) Ruby (`>= 3.2.0`).
547
+
548
+ *Joel Hawksley*
549
+
550
+ * BREAKING: Remove `render_component` and `render` monkey patch configured with `render_monkey_patch_enabled`.
551
+
552
+ *Joel Hawksley*
553
+
554
+ * BREAKING: Remove support for variant names containing `.` to be consistent with Rails.
555
+
556
+ *Stephen Nelson*
557
+
558
+ * BREAKING: Use ActionView's `lookup_context` for picking templates instead of the request format.
559
+
560
+ 3.15 added support for using templates that match the request format, that is if `/resource.csv` is requested then
561
+ ViewComponents would pick `_component.csv.erb` over `_component.html.erb`.
562
+
563
+ With this release, the request format is no longer considered and instead ViewComponent will use the Rails logic
564
+ for picking the most appropriate template type, that is the csv template will be used if it matches the `Accept` header
565
+ or because the controller uses a `respond_to` block to pick the response format.
566
+
567
+ *Stephen Nelson*
568
+
569
+ * BREAKING: Rename internal methods to have `__vc_` prefix if they shouldn't be used by consumers. Make internal constants private. Make `Collection#components`, `Slotable#register_polymorphic_slot` private. Remove unused `ComponentError` class.
570
+
571
+ *Joel Hawksley*
572
+
573
+ * Fix bug where request-aware helpers didn't work outside of the request context.
574
+
575
+ *Joel Hawksley*, *Stephen Nelson*
576
+
577
+ * `ViewComponentsSystemTestController` shouldn't be useable outside of test environment
578
+
579
+ *Joel Hawksley*, *Stephen Nelson*
580
+
581
+ * Remove unnecessary ENABLE_RELOADING test suite flag.
582
+
583
+ *Joel Hawksley*
584
+
585
+ * Add test coverage for uncovered code.
586
+
587
+ *Joel Hawksley*
588
+
589
+ * Remove unnecessary `#format` methods that returned `nil`.
590
+
591
+ *Joel Hawksley*
592
+
593
+ * Clean up project dependencies, relaxing versions of development gems.
594
+
595
+ *Joel Hawksley*
596
+
597
+ * Test against `turbo-rails` `v2`.
598
+
599
+ *Joel Hawksley*
600
+
601
+ * Test against `rspec-rails` `v7`.
602
+
603
+ *Joel Hawksley*
604
+
605
+ * Remove unnecessary usage of `ruby2_keywords`.
606
+
607
+ *Joel Hawksley*
608
+
609
+ * Remove unnecessary `respond_to` checks.
610
+
611
+ *Tiago Menegaz*, *Joel Hawksley*
612
+
613
+ * Introduce component-local config and migrate `strip_trailing_whitespace` to use it under the hood.
614
+
615
+ *Simon Fish*
616
+
617
+ * Deprecate `use_helper(s)`. Use `include MyHelper` or `helpers.` proxy instead.
618
+
619
+ *Joel Hawksley*
620
+
621
+ * Reduce string allocations during compilation.
622
+
623
+ *Jonathan del Strother*
624
+
13
625
  ## 3.23.2
14
626
 
15
627
  * Include .tt files in published gem. Fixes templates not being available when using generators.
@@ -66,10 +678,6 @@ nav_order: 6
66
678
 
67
679
  *Martin Meyerhoff*, *Joel Hawksley*
68
680
 
69
- * Add Content Harmony & Learn To Be to list of companies using ViewComponent.
70
-
71
- *Kane Jamison*
72
-
73
681
  * Clarify error message about render-dependent logic.
74
682
 
75
683
  Error messages about render-dependent logic were sometimes inaccurate, saying `during initialization` despite also being raised after a component had been initialized but before it was rendered.
@@ -88,10 +696,6 @@ nav_order: 6
88
696
 
89
697
  *Reegan Viljoen*
90
698
 
91
- * Add HomeStyler AI to list of companies using ViewComponent.
92
-
93
- *JP Balarini*
94
-
95
699
  ## 3.21.0
96
700
 
97
701
  * Updates testing docs to include an example of how to use with RSpec.
@@ -102,10 +706,6 @@ nav_order: 6
102
706
 
103
707
  *KAWAKAMI Moeki*
104
708
 
105
- * Add FreeATS to list of companies using ViewComponent.
106
-
107
- *Ilia Liamshin*
108
-
109
709
  * Ensure HTML output safety wrapper is used for all inline templates.
110
710
 
111
711
  *Joel Hawksley*
@@ -156,10 +756,6 @@ nav_order: 6
156
756
 
157
757
  *Blake Williams*
158
758
 
159
- * Add [Niva]([niva.co](https://www.niva.co/)) to companies who use `ViewComponent`.
160
-
161
- *Daniel Vu Dao*
162
-
163
759
  * Fix `preview_paths` in docs.
164
760
 
165
761
  *Javier Aranda*
@@ -224,10 +820,6 @@ nav_order: 6
224
820
 
225
821
  *Joel Hawksley*
226
822
 
227
- * Add Kicksite to list of companies using ViewComponent.
228
-
229
- *Adil Lari*
230
-
231
823
  * Allow overridden slot methods to use `super`.
232
824
 
233
825
  *Andrew Schwartz*
@@ -467,10 +1059,6 @@ nav_order: 6
467
1059
 
468
1060
  *Simon Fish*
469
1061
 
470
- * Add Simundia to list of companies using ViewComponent.
471
-
472
- *Alexandre Ignjatovic*
473
-
474
1062
  * Reduce UnboundMethod objects by memoizing initialize_parameters.
475
1063
 
476
1064
  *Rainer Borene*
@@ -521,10 +1109,6 @@ nav_order: 6
521
1109
 
522
1110
  *milk1000cc*
523
1111
 
524
- * Add PeopleForce to list of companies using ViewComponent.
525
-
526
- *Volodymyr Khandiuk*
527
-
528
1112
  ## 3.5.0
529
1113
 
530
1114
  * Add Skroutz to users list.
@@ -599,14 +1183,6 @@ nav_order: 6
599
1183
 
600
1184
  *Joel Hawksley*
601
1185
 
602
- * Add Ophelos to list of companies using ViewComponent.
603
-
604
- *Graham Rogers*
605
-
606
- * Add FlightLogger to list of companies using ViewComponent.
607
-
608
- *Joseph Carpenter*
609
-
610
1186
  * Fix coverage reports overwriting each other when running locally.
611
1187
 
612
1188
  *Jonathan del Strother*
@@ -846,14 +1422,6 @@ Run into an issue with this release? [Let us know](https://github.com/ViewCompon
846
1422
 
847
1423
  *Graham Rogers*
848
1424
 
849
- * Add Krystal to list of companies using ViewComponent.
850
-
851
- *Matt Bearman*
852
-
853
- * Add Mon Ami to list of companies using ViewComponent.
854
-
855
- *Ethan Lee-Tyson*
856
-
857
1425
  ## 3.0.0.rc1
858
1426
 
859
1427
  1,000+ days and 100+ releases later, the 200+ contributors to ViewComponent are proud to ship v3.0.0!
@@ -1002,10 +1570,6 @@ Run into an issue with this release? [Let us know](https://github.com/ViewCompon
1002
1570
 
1003
1571
  *Hans Lemuet*
1004
1572
 
1005
- * Add Startup Jobs to list of companies using ViewComponent.
1006
-
1007
- *Marc Köhlbrugge*
1008
-
1009
1573
  * Run PVC's accessibility tests in a single process to avoid resource contention in CI.
1010
1574
 
1011
1575
  *Cameron Dutro*
@@ -1046,10 +1610,6 @@ Run into an issue with this release? [Let us know](https://github.com/ViewCompon
1046
1610
 
1047
1611
  ## 2.74.0
1048
1612
 
1049
- * Add Avo to list of companies using ViewComponent.
1050
-
1051
- *Adrian Marin*
1052
-
1053
1613
  * Promote experimental `_output_postamble` method to public API as `output_postamble`.
1054
1614
 
1055
1615
  *Joel Hawksley*
@@ -1076,10 +1636,6 @@ Run into an issue with this release? [Let us know](https://github.com/ViewCompon
1076
1636
 
1077
1637
  *Erinna Chen*
1078
1638
 
1079
- * Add PrintReleaf to list of companies using ViewComponent.
1080
-
1081
- *Ry Kulp*
1082
-
1083
1639
  * Simplify CI configuration to a single build per Ruby/Rails version.
1084
1640
 
1085
1641
  *Joel Hawksley*
@@ -1088,10 +1644,6 @@ Run into an issue with this release? [Let us know](https://github.com/ViewCompon
1088
1644
 
1089
1645
  *Ruben Smit*
1090
1646
 
1091
- * Add Yobbers to list of companies using ViewComponent.
1092
-
1093
- *Anton Prins*
1094
-
1095
1647
  ## 2.72.0
1096
1648
 
1097
1649
  * Deprecate support for Ruby < 2.7 for removal in v3.0.0.
@@ -1106,10 +1658,6 @@ Run into an issue with this release? [Let us know](https://github.com/ViewCompon
1106
1658
 
1107
1659
  *Joel Hawksley.
1108
1660
 
1109
- * Add Aluuno to list of companies using ViewComponent.
1110
-
1111
- *Daniel Naves de Carvalho*
1112
-
1113
1661
  * Add `source_code_uri` to gemspec.
1114
1662
 
1115
1663
  *Yoshiyuki Hirano*
@@ -1144,22 +1692,10 @@ Run into an issue with this release? [Let us know](https://github.com/ViewCompon
1144
1692
 
1145
1693
  *Joel Hawksley*
1146
1694
 
1147
- * Add Arrows to list of companies using ViewComponent.
1148
-
1149
- *Matt Swanson*
1150
-
1151
- * Add WIP to list of companies using ViewComponent.
1152
-
1153
- *Marc Köhlbrugge*
1154
-
1155
1695
  * Update slots documentation to include how to reference slots.
1156
1696
 
1157
1697
  *Brittany Ellich*
1158
1698
 
1159
- * Add Clio to list of companies using ViewComponent.
1160
-
1161
- *Mike Buckley*
1162
-
1163
1699
  ## 2.69.0
1164
1700
 
1165
1701
  * Add missing `require` to fix `pvc` build.
@@ -1277,10 +1813,6 @@ Run into an issue with this release? [Let us know](https://github.com/ViewCompon
1277
1813
 
1278
1814
  *Vikram Dighe*
1279
1815
 
1280
- * Add HappyCo to list of companies using ViewComponent.
1281
-
1282
- *Josh Clayton*
1283
-
1284
1816
  * Add predicate method support to polymorphic slots.
1285
1817
 
1286
1818
  *Graham Rogers*
@@ -1391,10 +1923,6 @@ Run into an issue with this release? [Let us know](https://github.com/ViewCompon
1391
1923
 
1392
1924
  *Thomas Hutterer*
1393
1925
 
1394
- * Add FreeAgent to list of companies using ViewComponent.
1395
-
1396
- *Simon Fish*
1397
-
1398
1926
  * Include polymorphic slots in `ViewComponent::Base` by default.
1399
1927
 
1400
1928
  *Cameron Dutro*
@@ -1450,18 +1978,6 @@ Run into an issue with this release? [Let us know](https://github.com/ViewCompon
1450
1978
 
1451
1979
  *Joel Hawksley*
1452
1980
 
1453
- * Add G2 to list of companies that use ViewComponent.
1454
-
1455
- *Jack Shuff*
1456
-
1457
- * Add Within3 to list of companies that use ViewComponent.
1458
-
1459
- *Drew Bragg*
1460
-
1461
- * Add Mission Met to list of companies that use ViewComponent.
1462
-
1463
- *Nick Smith*
1464
-
1465
1981
  * Fix `#with_request_url` test helper not parsing nested query parameters into nested hashes.
1466
1982
 
1467
1983
  *Richard Marbach*
@@ -1501,10 +2017,6 @@ Run into an issue with this release? [Let us know](https://github.com/ViewCompon
1501
2017
 
1502
2018
  *Blake Williams*
1503
2019
 
1504
- * Add QuickNode to list of companies that use ViewComponent.
1505
-
1506
- *Luc Castera*
1507
-
1508
2020
  * Include the `Translatable` module by default.
1509
2021
 
1510
2022
  *Elia Schito*
@@ -1535,10 +2047,6 @@ Run into an issue with this release? [Let us know](https://github.com/ViewCompon
1535
2047
 
1536
2048
  *Jason Swett*
1537
2049
 
1538
- * Add Bearer to list of companies that use ViewComponent.
1539
-
1540
- *Yaroslav Shmarov*
1541
-
1542
2050
  * Add articles to resources page.
1543
2051
 
1544
2052
  *Joel Hawksley*
@@ -1568,10 +2076,6 @@ Run into an issue with this release? [Let us know](https://github.com/ViewCompon
1568
2076
 
1569
2077
  *Hans Lemuet*
1570
2078
 
1571
- * Alphabetize companies using ViewComponent and add Brightline to the list.
1572
-
1573
- *Jack Schuss*
1574
-
1575
2079
  * Add CMYK value for ViewComponent Red color on logo page.
1576
2080
 
1577
2081
  *Dylan Smith*