view_component 2.50.0 → 2.69.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/LICENSE.txt +1 -1
- data/app/assets/vendor/prism.css +3 -195
- data/app/assets/vendor/prism.min.js +11 -11
- data/app/controllers/concerns/view_component/preview_actions.rb +97 -0
- data/app/controllers/view_components_controller.rb +1 -87
- data/app/helpers/preview_helper.rb +5 -5
- data/app/views/view_components/preview.html.erb +2 -2
- data/docs/CHANGELOG.md +427 -1
- data/lib/rails/generators/abstract_generator.rb +7 -9
- data/lib/rails/generators/component/component_generator.rb +5 -4
- data/lib/rails/generators/locale/component_generator.rb +1 -1
- data/lib/rails/generators/preview/component_generator.rb +1 -1
- data/lib/view_component/base.rb +152 -51
- data/lib/view_component/collection.rb +9 -2
- data/lib/view_component/compiler.rb +39 -18
- data/lib/view_component/config.rb +159 -0
- data/lib/view_component/content_areas.rb +1 -1
- data/lib/view_component/docs_builder_component.rb +1 -1
- data/lib/view_component/engine.rb +16 -30
- data/lib/view_component/polymorphic_slots.rb +28 -1
- data/lib/view_component/preview.rb +12 -9
- data/lib/view_component/render_component_helper.rb +1 -0
- data/lib/view_component/render_component_to_string_helper.rb +1 -1
- data/lib/view_component/render_to_string_monkey_patch.rb +1 -1
- data/lib/view_component/rendering_component_helper.rb +1 -1
- data/lib/view_component/rendering_monkey_patch.rb +1 -1
- data/lib/view_component/slot_v2.rb +4 -10
- data/lib/view_component/slotable.rb +5 -6
- data/lib/view_component/slotable_v2.rb +69 -21
- data/lib/view_component/test_helpers.rb +80 -8
- data/lib/view_component/translatable.rb +13 -14
- data/lib/view_component/version.rb +1 -1
- data/lib/view_component.rb +1 -0
- metadata +47 -18
- data/lib/view_component/previewable.rb +0 -62
@@ -1,5 +1,5 @@
|
|
1
1
|
<% if @render_args[:component] %>
|
2
|
-
<% if ViewComponent::Base.render_monkey_patch_enabled || Rails.version.to_f >= 6.1 %>
|
2
|
+
<% if ViewComponent::Base.config.render_monkey_patch_enabled || Rails.version.to_f >= 6.1 %>
|
3
3
|
<%= render(@render_args[:component], @render_args[:args], &@render_args[:block]) %>
|
4
4
|
<% else %>
|
5
5
|
<%= render_component(@render_args[:component], &@render_args[:block]) %>
|
@@ -8,6 +8,6 @@
|
|
8
8
|
<%= render template: @render_args[:template], locals: @render_args[:locals] || {} %>
|
9
9
|
<% end %>
|
10
10
|
|
11
|
-
<% if ViewComponent::Base.show_previews_source %>
|
11
|
+
<% if ViewComponent::Base.config.show_previews_source %>
|
12
12
|
<%= preview_source %>
|
13
13
|
<% end %>
|
data/docs/CHANGELOG.md
CHANGED
@@ -3,10 +3,432 @@ layout: default
|
|
3
3
|
title: Changelog
|
4
4
|
---
|
5
5
|
|
6
|
+
<!-- Add unreleased changes under the "main" heading. -->
|
7
|
+
|
6
8
|
# Changelog
|
7
9
|
|
10
|
+
* Add missing `require` to fix `pvc` build.
|
11
|
+
|
12
|
+
*Joel Hawksley*
|
13
|
+
|
14
|
+
* Add `config.view_component.use_consistent_rendering_lifecycle` to ensure side-effects in `content` are consistently evaluated before components are rendered. This change effectively means that `content` is evaluated for every component render where `render?` returns true. As a result, code that's passed to a component via a block/content will now always be evaluated, before `#call`, which can reveal bugs in existing components. This configuration option defaults to `false` but will be enabled in 3.0 and the old behavior will be removed.
|
15
|
+
|
16
|
+
*Blake Williams*
|
17
|
+
|
8
18
|
## main
|
9
19
|
|
20
|
+
## 2.69.0
|
21
|
+
|
22
|
+
* Update Prism to version 1.28.0.
|
23
|
+
|
24
|
+
*Thomas Hutterer*
|
25
|
+
|
26
|
+
* Corrects the deprecation warning for named slots to show the file and line where the slot is called.
|
27
|
+
|
28
|
+
*River Bailey*
|
29
|
+
|
30
|
+
## 2.68.0
|
31
|
+
|
32
|
+
* Update `gemspec` author to be ViewComponent team.
|
33
|
+
|
34
|
+
*Joel Hawksley*
|
35
|
+
|
36
|
+
* Fix bug where `ViewComponent::Compiler` wasn't required.
|
37
|
+
|
38
|
+
*Joel Hawksley*
|
39
|
+
|
40
|
+
## 2.67.0
|
41
|
+
|
42
|
+
* Use ViewComponent::Base.config as the internal endpoint for config.
|
43
|
+
|
44
|
+
*Simon Fish*
|
45
|
+
|
46
|
+
* Fix bug where `#with_request_url`, when used with query string, set the incorrect `request.path` and `request.fullpath`.
|
47
|
+
|
48
|
+
*Franz Liedke*
|
49
|
+
|
50
|
+
* Add link to [ViewComponentAttributes](https://github.com/amba-Health/view_component_attributes) in Resources section of docs.
|
51
|
+
|
52
|
+
*Romaric Pascal*
|
53
|
+
|
54
|
+
* `render_preview` test helper is available by default. It is no longer necessary to include `ViewComponent::RenderPreviewHelper`.
|
55
|
+
|
56
|
+
*Joel Hawksley*
|
57
|
+
|
58
|
+
## 2.66.0
|
59
|
+
|
60
|
+
* Add missing `generate.sidecar`, `generate.stimulus_controller`, `generate.locale`, `generate.distinct_locale_files`, `generate.preview` config options to `config.view_component`.
|
61
|
+
|
62
|
+
*Simon Fish*
|
63
|
+
|
64
|
+
## 2.65.0
|
65
|
+
|
66
|
+
* Raise `ArgumentError` when conflicting Slots are defined.
|
67
|
+
|
68
|
+
Before this change it was possible to define Slots with conflicting names, for example:
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
class MyComponent < ViewComponent::Base
|
72
|
+
renders_one :item
|
73
|
+
renders_many :items
|
74
|
+
end
|
75
|
+
```
|
76
|
+
|
77
|
+
*Joel Hawksley*
|
78
|
+
|
79
|
+
## 2.64.0
|
80
|
+
|
81
|
+
* Add `warn_on_deprecated_slot_setter` flag to opt-in to deprecation warning.
|
82
|
+
|
83
|
+
In [v2.54.0](https://viewcomponent.org/CHANGELOG.html#2540), the Slots API was updated to require the `with_*` prefix for setting Slots. The non-`with_*` setters will be deprecated in a coming version and removed in `v3.0`.
|
84
|
+
|
85
|
+
To enable the coming deprecation warning, add `warn_on_deprecated_slot_setter`:
|
86
|
+
|
87
|
+
```ruby
|
88
|
+
class DeprecatedSlotsSetterComponent < ViewComponent::Base
|
89
|
+
warn_on_deprecated_slot_setter
|
90
|
+
end
|
91
|
+
```
|
92
|
+
|
93
|
+
*Joel Hawksley*
|
94
|
+
|
95
|
+
* Add [`m`](https://rubygems.org/gems/m) to development environment.
|
96
|
+
|
97
|
+
*Joel Hawksley*
|
98
|
+
|
99
|
+
* Fix potential deadlock scenario in the compiler's development mode.
|
100
|
+
|
101
|
+
*Blake Williams*
|
102
|
+
|
103
|
+
## 2.63.0
|
104
|
+
|
105
|
+
* Fixed typo in `renders_many` documentation.
|
106
|
+
|
107
|
+
*Graham Rogers*
|
108
|
+
|
109
|
+
* Add documentation about working with `turbo-rails`.
|
110
|
+
|
111
|
+
*Matheus Poli Camilo*
|
112
|
+
|
113
|
+
* Fix issue causing helper methods to not be available in nested components when the render monkey patch is disabled and `render_component` is used.
|
114
|
+
|
115
|
+
*Daniel Scheffknecht*
|
116
|
+
|
117
|
+
## 2.62.0
|
118
|
+
|
119
|
+
* Remove the experimental global output buffer feature.
|
120
|
+
* Restore functionality that used to attempt to compile templates on each call to `#render_in`.
|
121
|
+
* Un-pin `rails` `main` dependency.
|
122
|
+
|
123
|
+
*Cameron Dutro*
|
124
|
+
|
125
|
+
* Add blank space between "in" and "ViewComponent" in a deprecation warning.
|
126
|
+
|
127
|
+
*Vikram Dighe*
|
128
|
+
|
129
|
+
* Add HappyCo to list of companies using ViewComponent.
|
130
|
+
|
131
|
+
*Josh Clayton*
|
132
|
+
|
133
|
+
* Add predicate method support to polymorphic slots.
|
134
|
+
|
135
|
+
*Graham Rogers*
|
136
|
+
|
137
|
+
## 2.61.1
|
138
|
+
|
139
|
+
* Revert `Expose Capybara DSL methods directly inside tests.` This change unintentionally broke other Capybara methods and thus introduced a regression. We aren't confident that we can fail forward so we have decided to revert this change.
|
140
|
+
|
141
|
+
*Joel Hawksley*, *Blake Williams*
|
142
|
+
|
143
|
+
* Revert change making content evaluation consistent.
|
144
|
+
|
145
|
+
*Blake Williams*
|
146
|
+
|
147
|
+
* Pin `rails` `main` dependency due to incompatibility with Global Output Buffer.
|
148
|
+
|
149
|
+
*Joel Hawksley*
|
150
|
+
|
151
|
+
## 2.61.0
|
152
|
+
|
153
|
+
* Ensure side-effects in `content` are consistently evaluated before components are rendered. This change effectively means that `content` is evaluated for every component render where `render?` returns true. As a result, code that is passed to a component via a block/content will now always be evaluated, before `#call`, which can reveal bugs in existing components.
|
154
|
+
|
155
|
+
*Blake Williams*
|
156
|
+
|
157
|
+
## 2.60.0
|
158
|
+
|
159
|
+
* Add support for `render_preview` in RSpec tests.
|
160
|
+
|
161
|
+
*Thomas Hutterer*
|
162
|
+
|
163
|
+
## 2.59.0
|
164
|
+
|
165
|
+
* Expose Capybara DSL methods directly inside tests.
|
166
|
+
|
167
|
+
The following Capybara methods are now available directly without having to use the `page` method:
|
168
|
+
|
169
|
+
* [`all`](https://rubydoc.info/github/teamcapybara/capybara/Capybara%2FNode%2FFinders:all)
|
170
|
+
* [`first`](https://rubydoc.info/github/teamcapybara/capybara/Capybara%2FNode%2FFinders:first)
|
171
|
+
* [`text`](https://rubydoc.info/github/teamcapybara/capybara/Capybara%2FNode%2FSimple:text)
|
172
|
+
* [`find`](https://rubydoc.info/github/teamcapybara/capybara/master/Capybara%2FNode%2FFinders:find)
|
173
|
+
* [`find_all`](https://rubydoc.info/github/teamcapybara/capybara/master/Capybara%2FNode%2FFinders:find_all)
|
174
|
+
* [`find_button`](https://rubydoc.info/github/teamcapybara/capybara/master/Capybara%2FNode%2FFinders:find_button)
|
175
|
+
* [`find_by_id`](https://rubydoc.info/github/teamcapybara/capybara/master/Capybara%2FNode%2FFinders:find_by_id)
|
176
|
+
* [`find_field`](https://rubydoc.info/github/teamcapybara/capybara/master/Capybara%2FNode%2FFinders:find_field)
|
177
|
+
* [`find_link`](https://rubydoc.info/github/teamcapybara/capybara/master/Capybara%2FNode%2FFinders:find_link)
|
178
|
+
* [`has_content?`](https://rubydoc.info/github/teamcapybara/capybara/master/Capybara%2FNode%2FMatchers:has_content%3F)
|
179
|
+
* [`has_text?`](https://rubydoc.info/github/teamcapybara/capybara/master/Capybara%2FNode%2FMatchers:has_text%3F)
|
180
|
+
* [`has_css?`](https://rubydoc.info/github/teamcapybara/capybara/master/Capybara%2FNode%2FMatchers:has_css%3F)
|
181
|
+
* [`has_no_content?`](https://rubydoc.info/github/teamcapybara/capybara/master/Capybara%2FNode%2FMatchers:has_no_content%3F)
|
182
|
+
* [`has_no_text?`](https://rubydoc.info/github/teamcapybara/capybara/master/Capybara%2FNode%2FMatchers:has_no_text%3F)
|
183
|
+
* [`has_no_css?`](https://rubydoc.info/github/teamcapybara/capybara/master/Capybara%2FNode%2FMatchers:has_no_css%3F)
|
184
|
+
* [`has_no_xpath?`](https://rubydoc.info/github/teamcapybara/capybara/master/Capybara%2FNode%2FMatchers:has_no_xpath%3F)
|
185
|
+
* [`has_xpath?`](https://rubydoc.info/github/teamcapybara/capybara/master/Capybara%2FNode%2FMatchers:has_xpath%3F)
|
186
|
+
* [`has_link?`](https://rubydoc.info/github/teamcapybara/capybara/master/Capybara%2FNode%2FMatchers:has_link%3F)
|
187
|
+
* [`has_no_link?`](https://rubydoc.info/github/teamcapybara/capybara/master/Capybara%2FNode%2FMatchers:has_no_link%3F)
|
188
|
+
* [`has_button?`](https://rubydoc.info/github/teamcapybara/capybara/master/Capybara%2FNode%2FMatchers:has_button%3F)
|
189
|
+
* [`has_no_button?`](https://rubydoc.info/github/teamcapybara/capybara/master/Capybara%2FNode%2FMatchers:has_no_button%3F)
|
190
|
+
* [`has_field?`](https://rubydoc.info/github/teamcapybara/capybara/master/Capybara%2FNode%2FMatchers:has_field%3F)
|
191
|
+
* [`has_no_field?`](https://rubydoc.info/github/teamcapybara/capybara/master/Capybara%2FNode%2FMatchers:has_no_field%3F)
|
192
|
+
* [`has_checked_field?`](https://rubydoc.info/github/teamcapybara/capybara/master/Capybara%2FNode%2FMatchers:has_checked_field%3F)
|
193
|
+
* [`has_unchecked_field?`](https://rubydoc.info/github/teamcapybara/capybara/master/Capybara%2FNode%2FMatchers:has_unchecked_field%3F)
|
194
|
+
* [`has_no_table?`](https://rubydoc.info/github/teamcapybara/capybara/master/Capybara%2FNode%2FMatchers:has_no_table%3F)
|
195
|
+
* [`has_table?`](https://rubydoc.info/github/teamcapybara/capybara/master/Capybara%2FNode%2FMatchers:has_table%3F)
|
196
|
+
* [`has_select?`](https://rubydoc.info/github/teamcapybara/capybara/master/Capybara%2FNode%2FMatchers:has_select%3F)
|
197
|
+
* [`has_no_select?`](https://rubydoc.info/github/teamcapybara/capybara/master/Capybara%2FNode%2FMatchers:has_no_select%3F)
|
198
|
+
* [`has_selector?`](https://rubydoc.info/github/teamcapybara/capybara/master/Capybara%2FNode%2FMatchers:has_selector%3F)
|
199
|
+
* [`has_no_selector?`](https://rubydoc.info/github/teamcapybara/capybara/master/Capybara%2FNode%2FMatchers:has_no_selector%3F)
|
200
|
+
* [`has_no_checked_field?`](https://rubydoc.info/github/teamcapybara/capybara/master/Capybara%2FNode%2FMatchers:has_no_checked_field%3F)
|
201
|
+
* [`has_no_unchecked_field?`](https://rubydoc.info/github/teamcapybara/capybara/master/Capybara%2FNode%2FMatchers:has_no_unchecked_field%3F)
|
202
|
+
|
203
|
+
* Add support for `within*` Capybara DLS methods:
|
204
|
+
|
205
|
+
* [`within`](https://rubydoc.info/github/teamcapybara/capybara/master/Capybara%2FSession:within)
|
206
|
+
* [`within_element`](https://rubydoc.info/github/teamcapybara/capybara/master/Capybara%2FSession:within)
|
207
|
+
* [`within_fieldset`](https://rubydoc.info/github/teamcapybara/capybara/master/Capybara%2FSession:within_fieldset)
|
208
|
+
* [`within_table`](https://rubydoc.info/github/teamcapybara/capybara/master/Capybara%2FSession:within_table)
|
209
|
+
|
210
|
+
*Jacob Carlborg*
|
211
|
+
|
212
|
+
## 2.58.0
|
213
|
+
|
214
|
+
* Switch to `standardrb`.
|
215
|
+
|
216
|
+
*Joel Hawksley*
|
217
|
+
|
218
|
+
* Add BootrAils article to resources.
|
219
|
+
|
220
|
+
*Joel Hawksley*
|
221
|
+
|
222
|
+
* Add @boardfish and @spone as maintainers.
|
223
|
+
|
224
|
+
*Joel Hawksley*, *Cameron Dutro*, *Blake Williams*
|
225
|
+
|
226
|
+
* Re-compile updated, inherited templates when class caching is disabled.
|
227
|
+
|
228
|
+
*Patrick Arnett*
|
229
|
+
|
230
|
+
* Add the latest version to the docs index.
|
231
|
+
* Improve the docs: add the versions various features were introduced in.
|
232
|
+
|
233
|
+
*Hans Lemuet*
|
234
|
+
|
235
|
+
* Update docs to reflect lack of block content support in controllers.
|
236
|
+
|
237
|
+
*Joel Hawksley*
|
238
|
+
|
239
|
+
* Prevent adding duplicates to `autoload_paths`.
|
240
|
+
|
241
|
+
*Thomas Hutterer*
|
242
|
+
|
243
|
+
* Add FreeAgent to list of companies using ViewComponent.
|
244
|
+
|
245
|
+
*Simon Fish*
|
246
|
+
|
247
|
+
* Include polymorphic slots in `ViewComponent::Base` by default.
|
248
|
+
|
249
|
+
*Cameron Dutro*
|
250
|
+
|
251
|
+
* Add per-component config option for stripping newlines from templates before compilation.
|
252
|
+
|
253
|
+
*Cameron Dutro*
|
254
|
+
|
255
|
+
* Add link to article by Matouš Borák.
|
256
|
+
|
257
|
+
*Joel Hawksley*
|
258
|
+
|
259
|
+
## 2.57.1
|
260
|
+
|
261
|
+
* Fix issue causing `NoMethodError`s when calling helper methods from components rendered as part of a collection.
|
262
|
+
* Fix syntax error in the ERB example in the polymorphic slots docs.
|
263
|
+
|
264
|
+
*Cameron Dutro*
|
265
|
+
|
266
|
+
## 2.57.0
|
267
|
+
|
268
|
+
* Add missing `require` for `Translatable` module in `Base`.
|
269
|
+
|
270
|
+
*Hans Lemuet*
|
271
|
+
|
272
|
+
* Allow anything that responds to `#render_in` to be rendered in the parent component's view context.
|
273
|
+
|
274
|
+
*Cameron Dutro*
|
275
|
+
|
276
|
+
* Fix script/release so it honors semver.
|
277
|
+
|
278
|
+
*Cameron Dutro*
|
279
|
+
|
280
|
+
## 2.56.2
|
281
|
+
|
282
|
+
* Restore removed `rendered_component`, marking it for deprecation in v3.0.0.
|
283
|
+
|
284
|
+
*Tyson Gach*, *Richard Macklin*, *Joel Hawksley*
|
285
|
+
|
286
|
+
## 2.56.1
|
287
|
+
|
288
|
+
* Rename private accessor `rendered_component` to `rendered_content`.
|
289
|
+
|
290
|
+
*Yoshiyuki Hirano*, *Simon Dawson*
|
291
|
+
|
292
|
+
## 2.56.0
|
293
|
+
|
294
|
+
* Introduce experimental `render_preview` test helper. Note: `@rendered_component` in `TestHelpers` has been renamed to `@rendered_content`.
|
295
|
+
|
296
|
+
*Joel Hawksley*
|
297
|
+
|
298
|
+
* Move framework tests into sandbox application.
|
299
|
+
|
300
|
+
*Joel Hawksley*
|
301
|
+
|
302
|
+
* Add G2 to list of companies that use ViewComponent.
|
303
|
+
|
304
|
+
*Jack Shuff*
|
305
|
+
|
306
|
+
* Add Within3 to list of companies that use ViewComponent.
|
307
|
+
|
308
|
+
*Drew Bragg*
|
309
|
+
|
310
|
+
* Add Mission Met to list of companies that use ViewComponent.
|
311
|
+
|
312
|
+
*Nick Smith*
|
313
|
+
|
314
|
+
* Fix `#with_request_url` test helper not parsing nested query parameters into nested hashes.
|
315
|
+
|
316
|
+
*Richard Marbach*
|
317
|
+
|
318
|
+
## 2.55.0
|
319
|
+
|
320
|
+
* Add `render_parent` convenience method to avoid confusion between `<%= super %>` and `<% super %>` in template code.
|
321
|
+
|
322
|
+
*Cameron Dutro*
|
323
|
+
|
324
|
+
* Add note about discouraging inheritance.
|
325
|
+
|
326
|
+
*Joel Hawksley*
|
327
|
+
|
328
|
+
* Clean up grammar in documentation.
|
329
|
+
|
330
|
+
*Joel Hawksley*
|
331
|
+
|
332
|
+
* The ViewComponent team at GitHub is hiring! We're looking for a Rails engineer with accessibility experience: [https://boards.greenhouse.io/github/jobs/4020166](https://boards.greenhouse.io/github/jobs/4020166). Reach out to joelhawksley@github.com with any questions!
|
333
|
+
|
334
|
+
* The ViewComponent team is hosting a happy hour at RailsConf. Join us for snacks, drinks, and stickers: [https://www.eventbrite.com/e/viewcomponent-happy-hour-tickets-304168585427](https://www.eventbrite.com/e/viewcomponent-happy-hour-tickets-304168585427)
|
335
|
+
|
336
|
+
## 2.54.1
|
337
|
+
|
338
|
+
* Update docs dependencies.
|
339
|
+
|
340
|
+
*Joel Hawksley*
|
341
|
+
|
342
|
+
* Resolve warning in slots API.
|
343
|
+
* Raise in the test environment when ViewComponent code emits a warning.
|
344
|
+
|
345
|
+
*Blake Williams*
|
346
|
+
|
347
|
+
## 2.54.0
|
348
|
+
|
349
|
+
* Add `with_*` slot API for defining slots. Note: we plan to deprecate the non `with_*` API for slots in an upcoming release.
|
350
|
+
|
351
|
+
*Blake Williams*
|
352
|
+
|
353
|
+
* Add QuickNode to list of companies that use ViewComponent.
|
354
|
+
|
355
|
+
*Luc Castera*
|
356
|
+
|
357
|
+
* Include the `Translatable` module by default.
|
358
|
+
|
359
|
+
*Elia Schito*
|
360
|
+
|
361
|
+
* Update docs dependencies.
|
362
|
+
|
363
|
+
*Joel Hawksley*
|
364
|
+
|
365
|
+
## 2.53.0
|
366
|
+
|
367
|
+
* Add support for relative I18n scopes to translations.
|
368
|
+
|
369
|
+
*Elia Schito*
|
370
|
+
|
371
|
+
* Update CI configuration to use latest Rails 7.0.
|
372
|
+
|
373
|
+
*Hans Lemuet*
|
374
|
+
|
375
|
+
* Document how to use blocks with lambda slots.
|
376
|
+
|
377
|
+
*Sam Partington*
|
378
|
+
|
379
|
+
* Skip Rails 5.2 in local test environment if using incompatible Ruby version.
|
380
|
+
|
381
|
+
*Cameron Dutro*, *Blake Williams*, *Joel Hawksley*
|
382
|
+
|
383
|
+
* Improve landing page documentation.
|
384
|
+
|
385
|
+
*Jason Swett*
|
386
|
+
|
387
|
+
* Add Bearer to list of companies that use ViewComponent.
|
388
|
+
|
389
|
+
*Yaroslav Shmarov*
|
390
|
+
|
391
|
+
* Add articles to resources page.
|
392
|
+
|
393
|
+
*Joel Hawksley*
|
394
|
+
|
395
|
+
* Enable rendering arbitrary block contents in the view context in tests.
|
396
|
+
|
397
|
+
*Cameron Dutro*
|
398
|
+
|
399
|
+
## 2.52.0
|
400
|
+
|
401
|
+
* Add ADR for separate slot getter/setter API.
|
402
|
+
|
403
|
+
*Blake Williams*
|
404
|
+
|
405
|
+
* Add the option to use a "global" output buffer so `form_for` and friends can be used with view components.
|
406
|
+
|
407
|
+
*Cameron Dutro*, *Blake Williams*
|
408
|
+
|
409
|
+
* Fix fragment caching in partials when global output buffer is enabled.
|
410
|
+
* Fix template inheritance when eager loading is disabled.
|
411
|
+
|
412
|
+
*Cameron Dutro*
|
413
|
+
|
414
|
+
## 2.51.0
|
415
|
+
|
416
|
+
* Update the docs only when releasing a new version.
|
417
|
+
|
418
|
+
*Hans Lemuet*
|
419
|
+
|
420
|
+
* Alphabetize companies using ViewComponent and add Brightline to the list.
|
421
|
+
|
422
|
+
*Jack Schuss*
|
423
|
+
|
424
|
+
* Add CMYK value for ViewComponent Red color on logo page.
|
425
|
+
|
426
|
+
*Dylan Smith*
|
427
|
+
|
428
|
+
* Improve performance by moving template compilation from `#render_in` to `#render_template_for`.
|
429
|
+
|
430
|
+
*Cameron Dutro*
|
431
|
+
|
10
432
|
## 2.50.0
|
11
433
|
|
12
434
|
* Add tests for `layout` usage when rendering via controller.
|
@@ -91,10 +513,14 @@ title: Changelog
|
|
91
513
|
|
92
514
|
*Joel Hawksley*
|
93
515
|
|
94
|
-
* Add Ruby 3.1 and Rails 7.0 to CI
|
516
|
+
* Add Ruby 3.1 and Rails 7.0 to CI.
|
95
517
|
|
96
518
|
*Peter Goldstein*
|
97
519
|
|
520
|
+
* Move preview logic to module for easier app integration.
|
521
|
+
|
522
|
+
*Sammy Henningsson*
|
523
|
+
|
98
524
|
## 2.48.0
|
99
525
|
|
100
526
|
* Correct path in example test command in Contributing docs.
|
@@ -3,9 +3,7 @@
|
|
3
3
|
module ViewComponent
|
4
4
|
module AbstractGenerator
|
5
5
|
def copy_view_file
|
6
|
-
unless options["inline"]
|
7
|
-
template "component.html.#{engine_name}", destination
|
8
|
-
end
|
6
|
+
template "component.html.#{engine_name}", destination unless options["inline"]
|
9
7
|
end
|
10
8
|
|
11
9
|
private
|
@@ -31,20 +29,20 @@ module ViewComponent
|
|
31
29
|
end
|
32
30
|
|
33
31
|
def component_path
|
34
|
-
ViewComponent::Base.view_component_path
|
32
|
+
ViewComponent::Base.config.view_component_path
|
35
33
|
end
|
36
34
|
|
37
35
|
def stimulus_controller
|
38
36
|
if options["stimulus"]
|
39
|
-
File.join(destination_directory, destination_file_name)
|
40
|
-
sub("#{component_path}/", "")
|
41
|
-
|
42
|
-
gsub("/", "--")
|
37
|
+
File.join(destination_directory, destination_file_name)
|
38
|
+
.sub("#{component_path}/", "")
|
39
|
+
.tr("_", "-")
|
40
|
+
.gsub("/", "--")
|
43
41
|
end
|
44
42
|
end
|
45
43
|
|
46
44
|
def sidecar?
|
47
|
-
options["sidecar"] || ViewComponent::Base.generate.sidecar
|
45
|
+
options["sidecar"] || ViewComponent::Base.config.generate.sidecar
|
48
46
|
end
|
49
47
|
end
|
50
48
|
end
|
@@ -13,11 +13,12 @@ module Rails
|
|
13
13
|
check_class_collision suffix: "Component"
|
14
14
|
|
15
15
|
class_option :inline, type: :boolean, default: false
|
16
|
-
class_option :locale, type: :boolean, default: ViewComponent::Base.generate.locale
|
16
|
+
class_option :locale, type: :boolean, default: ViewComponent::Base.config.generate.locale
|
17
17
|
class_option :parent, type: :string, desc: "The parent class for the generated component"
|
18
|
-
class_option :preview, type: :boolean, default: ViewComponent::Base.generate.preview
|
18
|
+
class_option :preview, type: :boolean, default: ViewComponent::Base.config.generate.preview
|
19
19
|
class_option :sidecar, type: :boolean, default: false
|
20
|
-
class_option :stimulus, type: :boolean,
|
20
|
+
class_option :stimulus, type: :boolean,
|
21
|
+
default: ViewComponent::Base.config.generate.stimulus_controller
|
21
22
|
|
22
23
|
def create_component_file
|
23
24
|
template "component.rb", File.join(component_path, class_path, "#{file_name}_component.rb")
|
@@ -40,7 +41,7 @@ module Rails
|
|
40
41
|
def parent_class
|
41
42
|
return options[:parent] if options[:parent]
|
42
43
|
|
43
|
-
ViewComponent::Base.component_parent_class || default_parent_class
|
44
|
+
ViewComponent::Base.config.component_parent_class || default_parent_class
|
44
45
|
end
|
45
46
|
|
46
47
|
def initialize_signature
|
@@ -12,7 +12,7 @@ module Locale
|
|
12
12
|
class_option :sidecar, type: :boolean, default: false
|
13
13
|
|
14
14
|
def create_locale_file
|
15
|
-
if ViewComponent::Base.generate.distinct_locale_files
|
15
|
+
if ViewComponent::Base.config.generate.distinct_locale_files
|
16
16
|
I18n.available_locales.each do |locale|
|
17
17
|
create_file destination(locale), translations_hash([locale]).to_yaml
|
18
18
|
end
|
@@ -9,7 +9,7 @@ module Preview
|
|
9
9
|
check_class_collision suffix: "ComponentPreview"
|
10
10
|
|
11
11
|
def create_preview_file
|
12
|
-
preview_paths =
|
12
|
+
preview_paths = ViewComponent::Base.config.preview_paths
|
13
13
|
return if preview_paths.count > 1
|
14
14
|
|
15
15
|
path_prefix = preview_paths.one? ? preview_paths.first : "test/components/previews"
|