view_component 2.44.0 → 2.45.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.
- checksums.yaml +4 -4
- data/docs/CHANGELOG.md +60 -16
- data/lib/view_component/base.rb +10 -10
- data/lib/view_component/compile_cache.rb +1 -1
- data/lib/view_component/compiler.rb +1 -1
- data/lib/view_component/engine.rb +4 -1
- data/lib/view_component/preview.rb +1 -1
- data/lib/view_component/slot_v2.rb +2 -2
- data/lib/view_component/slotable.rb +4 -4
- data/lib/view_component/slotable_v2.rb +3 -3
- data/lib/view_component/test_helpers.rb +1 -1
- data/lib/view_component/version.rb +1 -1
- data/lib/view_component.rb +3 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a209f06f513d226dba5ddcfefe8c08d16f84da6d8664fd9a4f2f70fe1ef48d96
|
|
4
|
+
data.tar.gz: cc11c7e358b6fa3b07474a257202be93b0283c7c6189ce8d939770a805a28ef6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2420eadefc54d1045c432b7b53010281bd923b556b72d4ed924b49a0a88b1841800d6e04f25bb043913f5c648693d19ad56117e441c838e7eb09e0ab5cf21315
|
|
7
|
+
data.tar.gz: 4deb4c925810fcc2e3918e8735dd957003536e5533289d48caf69100dcb5ed58af6bb7af88fdc0cdf3c73e9905bb0222de18d9fd6cba65ca05e6bc3ed1f9964f
|
data/docs/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,44 @@ title: Changelog
|
|
|
7
7
|
|
|
8
8
|
## main
|
|
9
9
|
|
|
10
|
+
## 2.45.0
|
|
11
|
+
|
|
12
|
+
* Remove internal APIs from API documentation, fix link to license.
|
|
13
|
+
|
|
14
|
+
*Joel Hawksley*
|
|
15
|
+
|
|
16
|
+
* Add @yhirano55 to triage team.
|
|
17
|
+
|
|
18
|
+
*Joel Hawksley*
|
|
19
|
+
|
|
20
|
+
* Correct a typo in the sample slots code.
|
|
21
|
+
|
|
22
|
+
*Simon Fish*
|
|
23
|
+
|
|
24
|
+
* Add note about `allowed_queries`.
|
|
25
|
+
|
|
26
|
+
*Joel Hawksley*
|
|
27
|
+
|
|
28
|
+
* Add `vale` content linter.
|
|
29
|
+
|
|
30
|
+
*Joel Hawksley*
|
|
31
|
+
|
|
32
|
+
* Remove `require "rails/generators/test_case"` in generator tests.
|
|
33
|
+
|
|
34
|
+
*Yoshiyuki Hirano*
|
|
35
|
+
|
|
36
|
+
* Suppress zeitwerk warning about circular require.
|
|
37
|
+
|
|
38
|
+
*Yoshiyuki Hirano*
|
|
39
|
+
|
|
40
|
+
* Move `test_unit_generator_test.rb` from `test/view_component/` to `test/generators/`.
|
|
41
|
+
|
|
42
|
+
*Yoshiyuki Hirano*
|
|
43
|
+
|
|
44
|
+
* Unify test code of `TestUnitGeneratorTest` with the other generators tests.
|
|
45
|
+
|
|
46
|
+
*Yoshiyuki Hirano*
|
|
47
|
+
|
|
10
48
|
## 2.44.0
|
|
11
49
|
|
|
12
50
|
* Rename internal accessor to use private naming.
|
|
@@ -142,7 +180,7 @@ title: Changelog
|
|
|
142
180
|
|
|
143
181
|
*Matthew Rider*
|
|
144
182
|
|
|
145
|
-
* Fix bug where `with_collection_parameter`
|
|
183
|
+
* Fix bug where `with_collection_parameter` didn't inherit from parent component.
|
|
146
184
|
|
|
147
185
|
*Will Drexler*, *Christian Campoli*
|
|
148
186
|
|
|
@@ -346,7 +384,7 @@ title: Changelog
|
|
|
346
384
|
|
|
347
385
|
*Hans Lemuet*
|
|
348
386
|
|
|
349
|
-
* Fix bug where ViewComponents
|
|
387
|
+
* Fix bug where ViewComponents didn't work in ActionMailers.
|
|
350
388
|
|
|
351
389
|
*dark-panda*
|
|
352
390
|
|
|
@@ -394,7 +432,7 @@ title: Changelog
|
|
|
394
432
|
|
|
395
433
|
## 2.31.0
|
|
396
434
|
|
|
397
|
-
_Note: This release includes an underlying change to Slots that may affect incorrect usage of the API, where Slots were set on a line prefixed by `<%=`. The result of setting a Slot
|
|
435
|
+
_Note: This release includes an underlying change to Slots that may affect incorrect usage of the API, where Slots were set on a line prefixed by `<%=`. The result of setting a Slot shouldn't be returned. (`<%`)_
|
|
398
436
|
|
|
399
437
|
* Add `#with_content` to allow setting content without a block.
|
|
400
438
|
|
|
@@ -405,7 +443,7 @@ _Note: This release includes an underlying change to Slots that may affect incor
|
|
|
405
443
|
*Mario Schüttel*
|
|
406
444
|
|
|
407
445
|
* Improve feature parity with Rails translations
|
|
408
|
-
* Don't create a translation
|
|
446
|
+
* Don't create a translation back end if the component has no translation file
|
|
409
447
|
* Mark translation keys ending with `html` as HTML-safe
|
|
410
448
|
* Always convert keys to String
|
|
411
449
|
* Support multiple keys
|
|
@@ -447,7 +485,7 @@ _Note: This release includes an underlying change to Slots that may affect incor
|
|
|
447
485
|
|
|
448
486
|
*Alex Robbin, Blake Williams*
|
|
449
487
|
|
|
450
|
-
* Experimental: call `._sidecar_files` to fetch the sidecar files for a given list of extensions,
|
|
488
|
+
* Experimental: call `._sidecar_files` to fetch the sidecar files for a given list of extensions, for example passing `["yml", "yaml"]`.
|
|
451
489
|
|
|
452
490
|
*Elia Schito*
|
|
453
491
|
|
|
@@ -487,11 +525,11 @@ _Note: This release includes an underlying change to Slots that may affect incor
|
|
|
487
525
|
|
|
488
526
|
## 2.26.0
|
|
489
527
|
|
|
490
|
-
*
|
|
528
|
+
* Delay evaluating component `content` in `render?`, preventing the `content` block from being evaluated when `render?` returns false.
|
|
491
529
|
|
|
492
530
|
*Blake Williams*
|
|
493
531
|
|
|
494
|
-
*
|
|
532
|
+
* Don't generate template when using `--inline` flag.
|
|
495
533
|
|
|
496
534
|
*Hans Lemuet*
|
|
497
535
|
|
|
@@ -552,7 +590,7 @@ _Note: This release includes an underlying change to Slots that may affect incor
|
|
|
552
590
|
* `with_slot collection: true` becomes `renders_many`.
|
|
553
591
|
* Slot definitions now accept either a component class, component class name, or a lambda instead of a `class_name:` keyword argument.
|
|
554
592
|
* Slots now support positional arguments.
|
|
555
|
-
* Slots no longer use the `content` attribute to render content, instead relying on `to_s`.
|
|
593
|
+
* Slots no longer use the `content` attribute to render content, instead relying on `to_s`. for example `<%= my_slot %>`.
|
|
556
594
|
* Slot values are no longer set via the `slot` method, and instead use the name of the slot.
|
|
557
595
|
|
|
558
596
|
*Blake Williams*
|
|
@@ -615,7 +653,7 @@ _Note: This release includes an underlying change to Slots that may affect incor
|
|
|
615
653
|
|
|
616
654
|
## 2.18.2
|
|
617
655
|
|
|
618
|
-
* Raise an error if controller or view context is accessed during initialize as they
|
|
656
|
+
* Raise an error if controller or view context is accessed during initialize as they're only available in render.
|
|
619
657
|
|
|
620
658
|
*Julian Nadeau*
|
|
621
659
|
|
|
@@ -631,7 +669,7 @@ _Note: This release includes an underlying change to Slots that may affect incor
|
|
|
631
669
|
|
|
632
670
|
## 2.18.0
|
|
633
671
|
|
|
634
|
-
* Fix auto
|
|
672
|
+
* Fix auto loading of previews (changes no longer require a server restart)
|
|
635
673
|
|
|
636
674
|
*Matt Brictson*
|
|
637
675
|
|
|
@@ -724,7 +762,7 @@ _Note: This release includes an underlying change to Slots that may affect incor
|
|
|
724
762
|
|
|
725
763
|
## 2.10.0
|
|
726
764
|
|
|
727
|
-
* Raise an `ArgumentError` with a helpful message when Ruby
|
|
765
|
+
* Raise an `ArgumentError` with a helpful message when Ruby can't parse a component class.
|
|
728
766
|
|
|
729
767
|
*Max Beizer*
|
|
730
768
|
|
|
@@ -816,7 +854,7 @@ _Note: This release includes an underlying change to Slots that may affect incor
|
|
|
816
854
|
|
|
817
855
|
## v2.2.1
|
|
818
856
|
|
|
819
|
-
* Fix bug where template
|
|
857
|
+
* Fix bug where template couldn't be found if `inherited` was redefined.
|
|
820
858
|
|
|
821
859
|
*Joel Hawksley*
|
|
822
860
|
|
|
@@ -832,7 +870,7 @@ _Note: This release includes an underlying change to Slots that may affect incor
|
|
|
832
870
|
|
|
833
871
|
## v2.1.0
|
|
834
872
|
|
|
835
|
-
* Support rendering collections (
|
|
873
|
+
* Support rendering collections (for example, `render(MyComponent.with_collection(@items))`).
|
|
836
874
|
|
|
837
875
|
*Tim Clem*
|
|
838
876
|
|
|
@@ -854,7 +892,7 @@ _Note: This release includes an underlying change to Slots that may affect incor
|
|
|
854
892
|
|
|
855
893
|
*Andrew Mason*
|
|
856
894
|
|
|
857
|
-
* ViewComponent generators
|
|
895
|
+
* ViewComponent generators don't not prompt for content requirement.
|
|
858
896
|
|
|
859
897
|
*Joel Hawksley*
|
|
860
898
|
|
|
@@ -976,7 +1014,7 @@ _Note: This release includes an underlying change to Slots that may affect incor
|
|
|
976
1014
|
|
|
977
1015
|
*Jon Palmer*
|
|
978
1016
|
|
|
979
|
-
* Add `#render?` hook to
|
|
1017
|
+
* Add `#render?` hook to allow components to be no-ops.
|
|
980
1018
|
|
|
981
1019
|
*Kyle Fox*
|
|
982
1020
|
|
|
@@ -1044,7 +1082,9 @@ _Note: This release includes an underlying change to Slots that may affect incor
|
|
|
1044
1082
|
|
|
1045
1083
|
* Fix edge case issue with extracting variants from less conventional source_locations.
|
|
1046
1084
|
|
|
1085
|
+
<!-- vale proselint.GenderBias = NO -->
|
|
1047
1086
|
*Ryan Workman*
|
|
1087
|
+
<!-- vale proselint.GenderBias = YES -->
|
|
1048
1088
|
|
|
1049
1089
|
## v1.6.0
|
|
1050
1090
|
|
|
@@ -1080,7 +1120,9 @@ _Note: This release includes an underlying change to Slots that may affect incor
|
|
|
1080
1120
|
|
|
1081
1121
|
* Add support for RSpec to generators.
|
|
1082
1122
|
|
|
1123
|
+
<!-- vale proselint.GenderBias = NO -->
|
|
1083
1124
|
*Dylan Clark, Ryan Workman*
|
|
1125
|
+
<!-- vale proselint.GenderBias = YES -->
|
|
1084
1126
|
|
|
1085
1127
|
* Require controllers as part of setting autoload paths.
|
|
1086
1128
|
|
|
@@ -1104,7 +1146,9 @@ Note: `actionview-component` is now loaded by requiring `actionview/component`,
|
|
|
1104
1146
|
|
|
1105
1147
|
* Fix issue with generating component method signatures.
|
|
1106
1148
|
|
|
1149
|
+
<!-- vale proselint.GenderBias = NO -->
|
|
1107
1150
|
*Ryan Workman, Dylan Clark*
|
|
1151
|
+
<!-- vale proselint.GenderBias = YES -->
|
|
1108
1152
|
|
|
1109
1153
|
* Create component generator.
|
|
1110
1154
|
|
|
@@ -1176,7 +1220,7 @@ Note: `actionview-component` is now loaded by requiring `actionview/component`,
|
|
|
1176
1220
|
|
|
1177
1221
|
## v1.3.3
|
|
1178
1222
|
|
|
1179
|
-
*
|
|
1223
|
+
* Don't raise error when sidecar files that aren't templates exist.
|
|
1180
1224
|
|
|
1181
1225
|
*Joel Hawksley*
|
|
1182
1226
|
|
data/lib/view_component/base.rb
CHANGED
|
@@ -152,7 +152,7 @@ module ViewComponent
|
|
|
152
152
|
if view_context.nil?
|
|
153
153
|
raise(
|
|
154
154
|
ViewContextCalledBeforeRenderError,
|
|
155
|
-
"`#controller`
|
|
155
|
+
"`#controller` can't be used during initialization, as it depends " \
|
|
156
156
|
"on the view context that only exists once a ViewComponent is passed to " \
|
|
157
157
|
"the Rails render pipeline.\n\n" \
|
|
158
158
|
"It's sometimes possible to fix this issue by moving code dependent on " \
|
|
@@ -171,7 +171,7 @@ module ViewComponent
|
|
|
171
171
|
if view_context.nil?
|
|
172
172
|
raise(
|
|
173
173
|
ViewContextCalledBeforeRenderError,
|
|
174
|
-
"`#helpers`
|
|
174
|
+
"`#helpers` can't be used during initialization, as it depends " \
|
|
175
175
|
"on the view context that only exists once a ViewComponent is passed to " \
|
|
176
176
|
"the Rails render pipeline.\n\n" \
|
|
177
177
|
"It's sometimes possible to fix this issue by moving code dependent on " \
|
|
@@ -206,7 +206,7 @@ module ViewComponent
|
|
|
206
206
|
#
|
|
207
207
|
# @private
|
|
208
208
|
def format
|
|
209
|
-
# Ruby 2.6 throws a warning without checking `defined?`, 2.7
|
|
209
|
+
# Ruby 2.6 throws a warning without checking `defined?`, 2.7 doesn't
|
|
210
210
|
if defined?(@__vc_variant)
|
|
211
211
|
@__vc_variant
|
|
212
212
|
end
|
|
@@ -283,7 +283,7 @@ module ViewComponent
|
|
|
283
283
|
#
|
|
284
284
|
# config.view_component.view_component_path = "app/my_components"
|
|
285
285
|
#
|
|
286
|
-
# Defaults to
|
|
286
|
+
# Defaults to `app/components`.
|
|
287
287
|
mattr_accessor :view_component_path, instance_writer: false, default: "app/components"
|
|
288
288
|
|
|
289
289
|
# Parent class for generated components
|
|
@@ -318,7 +318,7 @@ module ViewComponent
|
|
|
318
318
|
|
|
319
319
|
# Add support for nested components defined in the same file.
|
|
320
320
|
#
|
|
321
|
-
#
|
|
321
|
+
# for example
|
|
322
322
|
#
|
|
323
323
|
# class MyComponent < ViewComponent::Base
|
|
324
324
|
# class MyOtherComponent < ViewComponent::Base
|
|
@@ -431,7 +431,7 @@ module ViewComponent
|
|
|
431
431
|
end
|
|
432
432
|
|
|
433
433
|
# Ensure the component initializer accepts the
|
|
434
|
-
# collection parameter. By default, we
|
|
434
|
+
# collection parameter. By default, we don't
|
|
435
435
|
# validate that the default parameter name
|
|
436
436
|
# is accepted, as support for collection
|
|
437
437
|
# rendering is optional.
|
|
@@ -442,7 +442,7 @@ module ViewComponent
|
|
|
442
442
|
return unless parameter
|
|
443
443
|
return if initialize_parameter_names.include?(parameter)
|
|
444
444
|
|
|
445
|
-
# If Ruby
|
|
445
|
+
# If Ruby can't parse the component class, then the initalize
|
|
446
446
|
# parameters will be empty and ViewComponent will not be able to render
|
|
447
447
|
# the component.
|
|
448
448
|
if initialize_parameters.empty?
|
|
@@ -455,14 +455,14 @@ module ViewComponent
|
|
|
455
455
|
end
|
|
456
456
|
|
|
457
457
|
raise ArgumentError.new(
|
|
458
|
-
"The initializer for #{self}
|
|
458
|
+
"The initializer for #{self} doesn't accept the parameter `#{parameter}`, " \
|
|
459
459
|
"which is required in order to render it as a collection.\n\n" \
|
|
460
460
|
"To fix this issue, update the initializer to accept `#{parameter}`.\n\n" \
|
|
461
461
|
"See https://viewcomponent.org/guide/collections.html for more information on rendering collections."
|
|
462
462
|
)
|
|
463
463
|
end
|
|
464
464
|
|
|
465
|
-
# Ensure the component initializer
|
|
465
|
+
# Ensure the component initializer doesn't define
|
|
466
466
|
# invalid parameters that could override the framework's
|
|
467
467
|
# methods.
|
|
468
468
|
# @private TODO: add documentation
|
|
@@ -470,7 +470,7 @@ module ViewComponent
|
|
|
470
470
|
return unless initialize_parameter_names.include?(RESERVED_PARAMETER)
|
|
471
471
|
|
|
472
472
|
raise ViewComponent::ComponentError.new(
|
|
473
|
-
"#{self} initializer
|
|
473
|
+
"#{self} initializer can't accept the parameter `#{RESERVED_PARAMETER}`, as it will override a " \
|
|
474
474
|
"public ViewComponent method. To fix this issue, rename the parameter."
|
|
475
475
|
)
|
|
476
476
|
end
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
module ViewComponent
|
|
4
4
|
# Keeps track of which templates have already been compiled
|
|
5
|
-
# This
|
|
5
|
+
# This isn't part of the public API
|
|
6
6
|
module CompileCache
|
|
7
7
|
mattr_accessor :cache, instance_reader: false, instance_accessor: false do
|
|
8
8
|
Set.new
|
|
@@ -95,7 +95,7 @@ module ViewComponent
|
|
|
95
95
|
errors = []
|
|
96
96
|
|
|
97
97
|
if (templates + inline_calls).empty?
|
|
98
|
-
errors << "
|
|
98
|
+
errors << "Couldn't find a template file or inline render method for #{component_class}."
|
|
99
99
|
end
|
|
100
100
|
|
|
101
101
|
if templates.count { |template| template[:variant].nil? } > 1
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "rails"
|
|
4
|
-
require "view_component"
|
|
5
4
|
|
|
6
5
|
module ViewComponent
|
|
7
6
|
class Engine < Rails::Engine # :nodoc:
|
|
@@ -145,3 +144,7 @@ module ViewComponent
|
|
|
145
144
|
end
|
|
146
145
|
end
|
|
147
146
|
end
|
|
147
|
+
|
|
148
|
+
# In the case of automatic loading, "view_component" is loaded first,
|
|
149
|
+
# so there is no need to load it.
|
|
150
|
+
require "view_component" unless defined?(ViewComponent::Base)
|
|
@@ -80,7 +80,7 @@ module ViewComponent # :nodoc:
|
|
|
80
80
|
if preview_path.nil?
|
|
81
81
|
raise(
|
|
82
82
|
PreviewTemplateError,
|
|
83
|
-
"A preview template for example #{example}
|
|
83
|
+
"A preview template for example #{example} doesn't exist.\n\n" \
|
|
84
84
|
"To fix this issue, create a template for the example."
|
|
85
85
|
)
|
|
86
86
|
end
|
|
@@ -20,7 +20,7 @@ module ViewComponent
|
|
|
20
20
|
# component, or a function that returns a component, we render that
|
|
21
21
|
# component instance, returning the string.
|
|
22
22
|
#
|
|
23
|
-
# If the slot renderable is a function and returns a string, it
|
|
23
|
+
# If the slot renderable is a function and returns a string, it's
|
|
24
24
|
# set as `@__vc_content` and is returned directly.
|
|
25
25
|
#
|
|
26
26
|
# If there is no slot renderable, we evaluate the block passed to
|
|
@@ -69,7 +69,7 @@ module ViewComponent
|
|
|
69
69
|
|
|
70
70
|
# Allow access to public component methods via the wrapper
|
|
71
71
|
#
|
|
72
|
-
#
|
|
72
|
+
# for example
|
|
73
73
|
#
|
|
74
74
|
# calling `header.name` (where `header` is a slot) will call `name`
|
|
75
75
|
# on the `HeaderComponent` instance.
|
|
@@ -29,12 +29,12 @@ module ViewComponent
|
|
|
29
29
|
)
|
|
30
30
|
|
|
31
31
|
slot_names.each do |slot_name|
|
|
32
|
-
# Ensure slot_name
|
|
32
|
+
# Ensure slot_name isn't already declared
|
|
33
33
|
if self.slots.key?(slot_name)
|
|
34
34
|
raise ArgumentError.new("#{slot_name} slot declared multiple times")
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
-
# Ensure slot name
|
|
37
|
+
# Ensure slot name isn't :content
|
|
38
38
|
if slot_name == :content
|
|
39
39
|
raise ArgumentError.new ":content is a reserved slot name. Please use another name, such as ':body'"
|
|
40
40
|
end
|
|
@@ -105,7 +105,7 @@ module ViewComponent
|
|
|
105
105
|
# <% end %>
|
|
106
106
|
#
|
|
107
107
|
def slot(slot_name, **args, &block)
|
|
108
|
-
# Raise ArgumentError if `slot`
|
|
108
|
+
# Raise ArgumentError if `slot` doesn't exist
|
|
109
109
|
unless slots.keys.include?(slot_name)
|
|
110
110
|
raise ArgumentError.new "Unknown slot '#{slot_name}' - expected one of '#{slots.keys}'"
|
|
111
111
|
end
|
|
@@ -140,7 +140,7 @@ module ViewComponent
|
|
|
140
140
|
instance_variable_set(slot[:instance_variable_name], slot_instance)
|
|
141
141
|
end
|
|
142
142
|
|
|
143
|
-
# Return nil, as this method
|
|
143
|
+
# Return nil, as this method shouldn't output anything to the view itself.
|
|
144
144
|
nil
|
|
145
145
|
end
|
|
146
146
|
end
|
|
@@ -121,7 +121,7 @@ module ViewComponent
|
|
|
121
121
|
singular_name = ActiveSupport::Inflector.singularize(slot_name)
|
|
122
122
|
|
|
123
123
|
# Define setter for singular names
|
|
124
|
-
#
|
|
124
|
+
# for example `renders_many :items` allows fetching all tabs with
|
|
125
125
|
# `component.tabs` and setting a tab with `component.tab`
|
|
126
126
|
define_method singular_name do |*args, &block|
|
|
127
127
|
set_slot(slot_name, nil, *args, &block)
|
|
@@ -181,7 +181,7 @@ module ViewComponent
|
|
|
181
181
|
# If callable is a string, we assume it's referencing an internal class
|
|
182
182
|
slot[:renderable_class_name] = callable
|
|
183
183
|
elsif callable.respond_to?(:call)
|
|
184
|
-
# If slot
|
|
184
|
+
# If slot doesn't respond to `render_in`, we assume it's a proc,
|
|
185
185
|
# define a method, and save a reference to it to call when setting
|
|
186
186
|
method_name = :"_call_#{slot_name}"
|
|
187
187
|
define_method method_name, &callable
|
|
@@ -256,7 +256,7 @@ module ViewComponent
|
|
|
256
256
|
# 1. If this is a `content_area` style sub-component, we will render the
|
|
257
257
|
# block via the `slot`
|
|
258
258
|
#
|
|
259
|
-
# 2. Since we
|
|
259
|
+
# 2. Since we've to pass block content to components when calling
|
|
260
260
|
# `render`, evaluating the block here would require us to call
|
|
261
261
|
# `view_context.capture` twice, which is slower
|
|
262
262
|
slot.__vc_content_block = block if block_given?
|
|
@@ -103,7 +103,7 @@ module ViewComponent
|
|
|
103
103
|
@controller = old_controller
|
|
104
104
|
end
|
|
105
105
|
|
|
106
|
-
# Set the URL
|
|
106
|
+
# Set the URL of the current request (such as when using request-dependent path helpers):
|
|
107
107
|
#
|
|
108
108
|
# ```ruby
|
|
109
109
|
# with_request_url("/users/42") do
|
data/lib/view_component.rb
CHANGED
|
@@ -19,4 +19,6 @@ module ViewComponent
|
|
|
19
19
|
autoload :Translatable
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
# In the case of manually loading, "view_component/engine" is loaded first,
|
|
23
|
+
# so there is no need to load it.
|
|
24
|
+
require "view_component/engine" if defined?(Rails::Engine) && !defined?(ViewComponent::Engine)
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: view_component
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.45.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- GitHub Open Source
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2021-11-
|
|
11
|
+
date: 2021-11-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|