view_component 4.0.0.alpha7 → 4.0.0.rc2
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 +86 -5
- data/lib/view_component/base.rb +16 -1
- data/lib/view_component/system_spec_helpers.rb +11 -0
- data/lib/view_component/template.rb +1 -2
- data/lib/view_component/version.rb +1 -1
- data/lib/view_component.rb +1 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cfdffe5b162240d97c986ddbdee4f537e04bddebde4f622a573c691599a73bed
|
4
|
+
data.tar.gz: d98395c2fe7910511a22da7a42864fa9a3c7c47c3a865be52defd3e54ad0b7c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8a6d36f48196994b26af63743dd1f9cbf9cf3bd71cd656e2de9b6f34a8fb69c5620e348dd9b791c1d59864627f6d0dc1fb7d56e50ad5e1a1376c611bd555864
|
7
|
+
data.tar.gz: ec1366449379c2817bc18e8c8fd565e0aee7a564c99a5c6c564d8da5ee2f60ae5582c1d46fbef25af532fc2e96a5c9b1de5d5e0907850c3af78b394ca49b772d
|
data/docs/CHANGELOG.md
CHANGED
@@ -10,6 +10,87 @@ nav_order: 6
|
|
10
10
|
|
11
11
|
## main
|
12
12
|
|
13
|
+
## 4.0.0.rc2
|
14
|
+
|
15
|
+
* Add `around_render` lifecyle method for wrapping component rendering in custom instrumentation, etc.
|
16
|
+
|
17
|
+
*Joel Hawksley*, *Blake Williams*
|
18
|
+
|
19
|
+
## 4.0.0.rc1
|
20
|
+
|
21
|
+
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.
|
22
|
+
|
23
|
+
Please report any issues at [https://github.com/ViewComponent/view_component/issues](https://github.com/ViewComponent/view_component/issues).
|
24
|
+
|
25
|
+
### Breaking changes (production)
|
26
|
+
|
27
|
+
* 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.
|
28
|
+
* Require [non-EOL](https://endoflife.date/rails) Rails (`>= 7.1.0`) and Ruby (`>= 3.2.0`).
|
29
|
+
* Remove `render_component` and `render` monkey patch configured with `render_monkey_patch_enabled`.
|
30
|
+
* Remove deprecated `use_helper(s)`. Use `include MyHelper` or `helpers.` proxy instead.
|
31
|
+
* Support compatibility with `Dry::Initializer`. As a result, `EmptyOrInvalidInitializerError` will no longer be raised.
|
32
|
+
* 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.
|
33
|
+
* Remove `use_deprecated_instrumentation_name` configuration option. Events will always use `render.view_component` name.
|
34
|
+
* Remove unnecessary `#format` methods that returned `nil`.
|
35
|
+
* Remove support for variant names containing `.` to be consistent with Rails.
|
36
|
+
* 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.
|
37
|
+
* Use ActionView's `lookup_context` for picking templates instead of the request format.
|
38
|
+
|
39
|
+
3.15 added support for using templates that match the request format, that is if `/resource.csv` is requested then
|
40
|
+
ViewComponents would pick `_component.csv.erb` over `_component.html.erb`.
|
41
|
+
|
42
|
+
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.
|
43
|
+
|
44
|
+
### Breaking changes (dev/test)
|
45
|
+
|
46
|
+
* Rename `config.generate.component_parent_class` to `config.generate.parent_class`.
|
47
|
+
* Remove `config.test_controller` in favor of `vc_test_controller_class` test helper method.
|
48
|
+
* `config.component_parent_class` is now `config.generate.component_parent_class`, moving the generator-specific option to the generator configuration namespace.
|
49
|
+
* Move previews-related configuration (`enabled`, `route`, `paths`, `default_layout`, `controller`) to under `previews` namespace.
|
50
|
+
* `config.view_component_path` is now `config.generate.path`, as components have long since been able to exist in any directory.
|
51
|
+
* `--inline` generator option now generates inline template. Use `--call` to generate `#call` method.
|
52
|
+
* Remove broken integration with `rails stats` that ignored components outside of `app/components`.
|
53
|
+
* Remove `preview_source` functionality. Consider using [Lookbook](https://lookbook.build/) instead.
|
54
|
+
* Use `Nokogiri::HTML5` instead of `Nokogiri::HTML4` for test helpers.
|
55
|
+
* Move generators to a ViewComponent namespace.
|
56
|
+
|
57
|
+
Before, ViewComponent generators pollute the generator namespace with a bunch of top level items, and claim the generic "component" name.
|
58
|
+
|
59
|
+
Now, generators live in a "view_component" module/namespace, so what was before `rails g
|
60
|
+
component` is now `rails g view_component:component`.
|
61
|
+
|
62
|
+
### New features
|
63
|
+
|
64
|
+
* Add `SystemSpecHelpers` for use with RSpec.
|
65
|
+
* Add support for including `Turbo::StreamsHelper`.
|
66
|
+
* Add template annotations for components with `def call`.
|
67
|
+
* Graduate `SlotableDefault` to be included by default.
|
68
|
+
* Add `#current_template` accessor and `Template#path` for diagnostic usage.
|
69
|
+
* Reduce string allocations during compilation.
|
70
|
+
|
71
|
+
### Bug fixes
|
72
|
+
|
73
|
+
* Fix bug where virtual path wasn't reset, breaking translations outside of components.
|
74
|
+
* Fix bug where `config.previews.enabled` didn't function properly in production environments.
|
75
|
+
* Fix bug where response format wasn't set, which caused issues with Turbo Frames.
|
76
|
+
* Fix bug in `SlotableDefault` where default couldn't be overridden when content was passed as a block.
|
77
|
+
* Fix bug where request-aware helpers didn't work outside of the request context.
|
78
|
+
* `ViewComponentsSystemTestController` shouldn't be useable outside of test environment
|
79
|
+
|
80
|
+
### Non-functional changes
|
81
|
+
|
82
|
+
* Remove unnecessary usage of `ruby2_keywords`.
|
83
|
+
* Remove unnecessary `respond_to` checks.
|
84
|
+
* Require MFA when publishing to RubyGems.
|
85
|
+
* Clean up project dependencies, relaxing versions of development gems.
|
86
|
+
* Add test case for absolute URL path helpers in mailers.
|
87
|
+
* Update documentation on performance to reflect more representative benchmark showing 2-3x speed increase over partials.
|
88
|
+
* Add documentation note about instrumentation negatively affecting performance.
|
89
|
+
* Remove unnecessary ENABLE_RELOADING test suite flag.
|
90
|
+
* `config.previews.default_layout` should default to nil.
|
91
|
+
* Add test coverage for uncovered code.
|
92
|
+
* Test against `turbo-rails` `v2` and `rspec-rails` `v7`.
|
93
|
+
|
13
94
|
## 4.0.0.alpha7
|
14
95
|
|
15
96
|
* BREAKING: Remove deprecated `use_helper(s)`. Use `include MyHelper` or `helpers.` proxy instead.
|
@@ -24,7 +105,7 @@ nav_order: 6
|
|
24
105
|
|
25
106
|
*Joel Hawksley*
|
26
107
|
|
27
|
-
* Fix bug where `config.previews.enabled`
|
108
|
+
* Fix bug where `config.previews.enabled` didn't function properly in production environments.
|
28
109
|
|
29
110
|
*Joel Hawksley*
|
30
111
|
|
@@ -159,11 +240,11 @@ This release makes the following breaking changes:
|
|
159
240
|
|
160
241
|
* BREAKING: Use ActionView's `lookup_context` for picking templates instead of the request format.
|
161
242
|
|
162
|
-
3.15 added support for using templates that match the request format,
|
243
|
+
3.15 added support for using templates that match the request format, that is if `/resource.csv` is requested then
|
163
244
|
ViewComponents would pick `_component.csv.erb` over `_component.html.erb`.
|
164
245
|
|
165
246
|
With this release, the request format is no longer considered and instead ViewComponent will use the Rails logic
|
166
|
-
for picking the most appropriate template type,
|
247
|
+
for picking the most appropriate template type, that is the csv template will be used if it matches the `Accept` header
|
167
248
|
or because the controller uses a `respond_to` block to pick the response format.
|
168
249
|
|
169
250
|
*Stephen Nelson*
|
@@ -172,11 +253,11 @@ This release makes the following breaking changes:
|
|
172
253
|
|
173
254
|
*Joel Hawksley*
|
174
255
|
|
175
|
-
* Fix bug where request-aware helpers
|
256
|
+
* Fix bug where request-aware helpers didn't work outside of the request context.
|
176
257
|
|
177
258
|
*Joel Hawksley*, *Stephen Nelson*
|
178
259
|
|
179
|
-
* `ViewComponentsSystemTestController`
|
260
|
+
* `ViewComponentsSystemTestController` shouldn't be useable outside of test environment
|
180
261
|
|
181
262
|
*Joel Hawksley*, *Stephen Nelson*
|
182
263
|
|
data/lib/view_component/base.rb
CHANGED
@@ -108,6 +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
112
|
self.__vc_original_view_context ||= view_context
|
112
113
|
|
113
114
|
@output_buffer = view_context.output_buffer
|
@@ -140,7 +141,12 @@ module ViewComponent
|
|
140
141
|
value = nil
|
141
142
|
|
142
143
|
@output_buffer.with_buffer do
|
143
|
-
|
144
|
+
@view_context.instance_variable_set(:@virtual_path, virtual_path)
|
145
|
+
|
146
|
+
rendered_template =
|
147
|
+
around_render do
|
148
|
+
render_template_for(@__vc_requested_details).to_s
|
149
|
+
end
|
144
150
|
|
145
151
|
# Avoid allocating new string when output_preamble and output_postamble are blank
|
146
152
|
value = if output_preamble.blank? && output_postamble.blank?
|
@@ -160,6 +166,7 @@ module ViewComponent
|
|
160
166
|
""
|
161
167
|
end
|
162
168
|
ensure
|
169
|
+
view_context.instance_variable_set(:@virtual_path, old_virtual_path)
|
163
170
|
@current_template = old_current_template
|
164
171
|
end
|
165
172
|
|
@@ -224,6 +231,14 @@ module ViewComponent
|
|
224
231
|
# noop
|
225
232
|
end
|
226
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
|
+
|
227
242
|
# Override to determine whether the ViewComponent should render.
|
228
243
|
#
|
229
244
|
# @return [Boolean]
|
@@ -98,9 +98,8 @@ module ViewComponent
|
|
98
98
|
@component.silence_redefinition_of_method(call_method_name)
|
99
99
|
|
100
100
|
# rubocop:disable Style/EvalWithLocation
|
101
|
-
@component.class_eval <<~RUBY, @path, @lineno
|
101
|
+
@component.class_eval <<~RUBY, @path, @lineno
|
102
102
|
def #{call_method_name}
|
103
|
-
@view_context.instance_variable_set(:@virtual_path, virtual_path)
|
104
103
|
#{compiled_source}
|
105
104
|
end
|
106
105
|
RUBY
|
data/lib/view_component.rb
CHANGED
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.
|
4
|
+
version: 4.0.0.rc2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ViewComponent Team
|
@@ -75,6 +75,7 @@ files:
|
|
75
75
|
- lib/view_component/request_details.rb
|
76
76
|
- lib/view_component/slot.rb
|
77
77
|
- lib/view_component/slotable.rb
|
78
|
+
- lib/view_component/system_spec_helpers.rb
|
78
79
|
- lib/view_component/system_test_case.rb
|
79
80
|
- lib/view_component/system_test_helpers.rb
|
80
81
|
- lib/view_component/template.rb
|
@@ -88,6 +89,7 @@ licenses:
|
|
88
89
|
- MIT
|
89
90
|
metadata:
|
90
91
|
allowed_push_host: https://rubygems.org
|
92
|
+
rubygems_mfa_required: 'true'
|
91
93
|
source_code_uri: https://github.com/viewcomponent/view_component
|
92
94
|
changelog_uri: https://github.com/ViewComponent/view_component/blob/main/docs/CHANGELOG.md
|
93
95
|
rdoc_options: []
|