view_component 4.0.0.alpha4 → 4.0.0.alpha6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 70feada9d7f9456623bfed2a6c76a9546f8fe5596f81e0f47ed7059808b1a68d
4
- data.tar.gz: 77d8002e2a0fdb344c3647972b9051ce1c3ac3bc299e49442c8631921a6b5437
3
+ metadata.gz: dbca6043a0eebf7c6f63358c7b1c193ef59170b81a35eb9290f211d365bfb3cb
4
+ data.tar.gz: 033db44d3dab35956b7ab8ac1a1a12673b7e82a0d4e0bbf3d3e791234dbcf757
5
5
  SHA512:
6
- metadata.gz: c3aeae640580d7d5c9192836fbc8ab26932a9527117438f4fa808fed36cd2c4393194fd66e5d01ddbc56bd0f0d5042b1707ee25b94760969b06a9d34a1700f85
7
- data.tar.gz: cb4ee57d927b7b9a27436ec1d736675ee59fe2dfc7aa281e8c6a1b9be87fa517849bc3443a6057a01f1a3e1b97320e8d566681dc989c452fa8c45ff261e058c9
6
+ metadata.gz: ddd3ac59908bf697da69f8f0fa29b2e779e468a07a6f37e96240165797fce088bbf6937473363d349b7e48fa8011434377b52345c8f60204ff94a7a794a4fee8
7
+ data.tar.gz: c8fac0e676aa9632453337a13169b690ed36bc9cd65e0de754c63f77878ba1b598c9a344f8f547a8b7c530c0e12c285de2fc0eee3afa4a1f7fe8805293414b8e
@@ -47,7 +47,7 @@ module ViewComponent
47
47
 
48
48
  # :doc:
49
49
  def default_preview_layout
50
- ViewComponent::Base.config.default_preview_layout
50
+ ViewComponent::Base.config.previews.default_layout
51
51
  end
52
52
 
53
53
  # :doc:
@@ -64,7 +64,11 @@ module ViewComponent
64
64
  if preview
65
65
  @preview = ViewComponent::Preview.find(preview)
66
66
  else
67
+ # TODO: This branch is covered in #test_returns_404_when_preview_does_not_exist,
68
+ # but Simplecov doesn't always mark it as covered.
69
+ # :nocov:
67
70
  raise AbstractController::ActionNotFound, "Component preview '#{params[:path]}' not found."
71
+ # :nocov:
68
72
  end
69
73
  end
70
74
 
@@ -95,7 +99,7 @@ module ViewComponent
95
99
  end
96
100
 
97
101
  def prepend_preview_examples_view_path
98
- prepend_view_path(ViewComponent::Base.preview_paths)
102
+ prepend_view_path(ViewComponent::Base.previews.paths)
99
103
  end
100
104
  end
101
105
  end
@@ -19,9 +19,7 @@ class ViewComponentsSystemTestController < ActionController::Base # :nodoc:
19
19
  def validate_file_path
20
20
  base_path = ::File.realpath(self.class.temp_dir)
21
21
  @path = ::File.realpath(params.permit(:file)[:file], base_path)
22
- unless @path.start_with?(base_path)
23
- raise ViewComponent::SystemTestControllerNefariousPathError
24
- end
22
+ raise ViewComponent::SystemTestControllerNefariousPathError unless @path.start_with?(base_path)
25
23
  end
26
24
  end
27
25
  end
data/docs/CHANGELOG.md CHANGED
@@ -10,6 +10,50 @@ nav_order: 6
10
10
 
11
11
  ## main
12
12
 
13
+ ## 4.0.0.alpha6
14
+
15
+ * BREAKING: Remove `config.test_controller` in favor of `vc_test_controller_class` test helper method.
16
+
17
+ *Joel Hawksley*
18
+
19
+ * BREAKING: `config.component_parent_class` is now `config.generate.component_parent_class`, moving the generator-specific option to the generator configuration namespace.
20
+
21
+ *Joel Hawksley*
22
+
23
+ * BREAKING: Move previews-related configuration (`enabled`, `route`, `paths`, `default_layout`, `controller`) to under `previews` namespace.
24
+
25
+ *Joel Hawksley*
26
+
27
+ * Add template annotations for components with `def call`.
28
+
29
+ *Joel Hawksley*
30
+
31
+ * Add support for including Turbo::StreamsHelper.
32
+
33
+ *Stephen Nelson*
34
+
35
+ * Update documentation on performance to reflect more representative benchmark showing 2-3x speed increase over partials.
36
+
37
+ *Joel Hawksley*
38
+
39
+ * Add documentation note about instrumentation negatively affecting performance.
40
+
41
+ *Joel Hawksley*
42
+
43
+ * Revert object shapes optimization due to lack of evidence of improvement.
44
+
45
+ *Joel Hawksley*
46
+
47
+ ## 4.0.0.alpha5
48
+
49
+ * BREAKING: `config.view_component_path` is now `config.generate.path`, as components have long since been able to exist in any directory.
50
+
51
+ *Joel Hawksley*
52
+
53
+ * BREAKING: Remove broken integration with `rails stats` that ignored components outside of `app/components`.
54
+
55
+ *Joel Hawksley*
56
+
13
57
  ## 4.0.0.alpha4
14
58
 
15
59
  * 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.
@@ -142,6 +186,24 @@ This release makes the following breaking changes:
142
186
 
143
187
  *Simon Fish*
144
188
 
189
+ * Reduce string allocations during compilation.
190
+
191
+ *Jonathan del Strother*
192
+
193
+ ## 3.23.2
194
+
195
+ * Include .tt files in published gem. Fixes templates not being available when using generators.
196
+
197
+ *Florian Aßmann*
198
+
199
+ ## 3.23.1
200
+
201
+ * Restore Rake tasks in published gem.
202
+
203
+ *Franz Liedke*
204
+
205
+ ## 3.23.0
206
+
145
207
  * Add docs about Slack channel in Ruby Central workspace. (Join us! #oss-view-component). Email joelhawksley@github.com for an invite.
146
208
 
147
209
  *Joel Hawksley
@@ -5,7 +5,6 @@ require "active_support/configurable"
5
5
  require "view_component/collection"
6
6
  require "view_component/compile_cache"
7
7
  require "view_component/compiler"
8
- require "view_component/component_local_config"
9
8
  require "view_component/config"
10
9
  require "view_component/errors"
11
10
  require "view_component/inline_template"
@@ -39,9 +38,10 @@ module ViewComponent
39
38
  #
40
39
  # @return [ActiveSupport::OrderedOptions]
41
40
  def config
42
- module_parents.each do |m|
43
- config = m.try(:config).try(:view_component)
44
- return config if config
41
+ module_parents.each do |module_parent|
42
+ next unless module_parent.respond_to?(:config)
43
+ module_parent_config = module_parent.config.try(:view_component)
44
+ return module_parent_config if module_parent_config
45
45
  end
46
46
  ViewComponent::Config.current
47
47
  end
@@ -56,7 +56,6 @@ module ViewComponent
56
56
  include ViewComponent::Slotable
57
57
  include ViewComponent::Translatable
58
58
  include ViewComponent::WithContentHelper
59
- include ViewComponent::ComponentLocalConfig
60
59
 
61
60
  # For CSRF authenticity tokens in forms
62
61
  delegate :form_authenticity_token, :protect_against_forgery?, :config, to: :helpers
@@ -64,9 +63,16 @@ module ViewComponent
64
63
  # HTML construction methods
65
64
  delegate :output_buffer, :lookup_context, :view_renderer, :view_flow, to: :helpers
66
65
 
66
+ # For Turbo::StreamsHelper
67
+ delegate :formats, :formats=, to: :helpers
68
+
67
69
  # For Content Security Policy nonces
68
70
  delegate :content_security_policy_nonce, to: :helpers
69
71
 
72
+ # Config option that strips trailing whitespace in templates before compiling them.
73
+ class_attribute :__vc_strip_trailing_whitespace, instance_accessor: false, instance_predicate: false
74
+ self.__vc_strip_trailing_whitespace = false # class_attribute:default doesn't work until Rails 5.2
75
+
70
76
  attr_accessor :__vc_original_view_context
71
77
  attr_reader :current_template
72
78
 
@@ -139,6 +145,11 @@ module ViewComponent
139
145
  end
140
146
  end
141
147
 
148
+ if ActionView::Base.annotate_rendered_view_with_filenames && current_template.inline_call? && request&.format == :html
149
+ identifier = defined?(Rails.root) ? self.class.identifier.sub("#{Rails.root}/", "") : self.class.identifier
150
+ value = "<!-- BEGIN #{identifier} -->".html_safe + value + "<!-- END #{identifier} -->".html_safe
151
+ end
152
+
142
153
  value
143
154
  else
144
155
  ""
@@ -363,35 +374,6 @@ module ViewComponent
363
374
  end
364
375
  end
365
376
 
366
- # Set the controller used for testing components:
367
- #
368
- # ```ruby
369
- # config.view_component.test_controller = "MyTestController"
370
- # ```
371
- #
372
- # Defaults to `nil`. If this is falsy, `"ApplicationController"` is used. Can also be
373
- # configured on a per-test basis using `with_controller_class`.
374
- #
375
-
376
- # Path for component files
377
- #
378
- # ```ruby
379
- # config.view_component.view_component_path = "app/my_components"
380
- # ```
381
- #
382
- # Defaults to `nil`. If this is falsy, `app/components` is used.
383
- #
384
-
385
- # Parent class for generated components
386
- #
387
- # ```ruby
388
- # config.view_component.component_parent_class = "MyBaseComponent"
389
- # ```
390
- #
391
- # Defaults to nil. If this is falsy, generators will use
392
- # "ApplicationComponent" if defined, "ViewComponent::Base" otherwise.
393
- #
394
-
395
377
  # Configuration for generators.
396
378
  #
397
379
  # All options under this namespace default to `false` unless otherwise
@@ -449,6 +431,18 @@ module ViewComponent
449
431
  # ```
450
432
  #
451
433
  # Defaults to `false`.
434
+ #
435
+ # #### component_parent_class
436
+ #
437
+ # Parent class for generated components
438
+ #
439
+ # ```ruby
440
+ # config.view_component.generate.component_parent_class = "MyBaseComponent"
441
+ # ```
442
+ #
443
+ # Defaults to nil. If this is falsy, generators will use
444
+ # "ApplicationComponent" if defined, "ViewComponent::Base" otherwise.
445
+ #
452
446
 
453
447
  class << self
454
448
  # The file path of the component Ruby file.
@@ -551,13 +545,7 @@ module ViewComponent
551
545
  # We use `base_label` method here instead of `label` to avoid cases where the method
552
546
  # owner is included in a prefix like `ApplicationComponent.inherited`.
553
547
  child.identifier = caller_locations(1, 10).reject { |l| l.base_label == "inherited" }[0].path
554
-
555
- # If Rails application is loaded, removes the first part of the path and the extension.
556
- if defined?(Rails) && Rails.application
557
- child.virtual_path = child.identifier.gsub(
558
- /(.*#{Regexp.quote(ViewComponent::Base.config.view_component_path)})|(\.rb)/, ""
559
- )
560
- end
548
+ child.virtual_path = child.name&.underscore
561
549
 
562
550
  # Set collection parameter to the extended component
563
551
  child.with_collection_parameter provided_collection_parameter
@@ -612,38 +600,16 @@ module ViewComponent
612
600
  # end
613
601
  # ```
614
602
  #
615
- # @deprecated Use the new component-local configuration option instead.
616
- #
617
- # ```ruby
618
- # class MyComponent < ViewComponent::Base
619
- # configure_view_component do |config|
620
- # config.strip_trailing_whitespace = true
621
- # end
622
- # end
623
- # ```
624
- #
625
603
  # @param value [Boolean] Whether to strip newlines.
626
604
  def strip_trailing_whitespace(value = true)
627
- ViewComponent::Deprecation.deprecation_warning(
628
- "strip_trailing_whitespace",
629
- <<~DOC
630
- Use the new component-local configuration option instead:
631
-
632
- class #{self.class.name} < ViewComponent::Base
633
- configure_view_component do |config|
634
- config.strip_trailing_whitespace = #{value}
635
- end
636
- end
637
- DOC
638
- )
639
- view_component_config.strip_trailing_whitespace = value
605
+ self.__vc_strip_trailing_whitespace = value
640
606
  end
641
607
 
642
608
  # Whether trailing whitespace will be stripped before compilation.
643
609
  #
644
610
  # @return [Boolean]
645
611
  def strip_trailing_whitespace?
646
- view_component_config.strip_trailing_whitespace
612
+ __vc_strip_trailing_whitespace
647
613
  end
648
614
 
649
615
  # Ensure the component initializer accepts the
@@ -108,10 +108,7 @@ module ViewComponent
108
108
 
109
109
  errors << "Couldn't find a template file or inline render method for #{@component}." if @templates.empty?
110
110
 
111
- # We currently allow components to have both an inline call method and a template for a variant, with the
112
- # inline call method overriding the template. We should aim to change this in v4 to instead
113
- # raise an error.
114
- @templates.reject(&:inline_call?)
111
+ @templates
115
112
  .map { |template| [template.variant, template.format] }
116
113
  .tally
117
114
  .select { |_, count| count > 1 }
@@ -13,15 +13,8 @@ module ViewComponent
13
13
  def defaults
14
14
  ActiveSupport::OrderedOptions.new.merge!({
15
15
  generate: default_generate_options,
16
- preview_controller: "ViewComponentsController",
17
- preview_route: "/rails/view_components",
18
- instrumentation_enabled: false,
19
- view_component_path: "app/components",
20
- component_parent_class: nil,
21
- show_previews: Rails.env.development? || Rails.env.test?,
22
- preview_paths: default_preview_paths,
23
- test_controller: "ApplicationController",
24
- default_preview_layout: nil
16
+ previews: default_previews_options,
17
+ instrumentation_enabled: false
25
18
  })
26
19
  end
27
20
 
@@ -32,6 +25,12 @@ module ViewComponent
32
25
  # All options under this namespace default to `false` unless otherwise
33
26
  # stated.
34
27
  #
28
+ # #### `#path`
29
+ #
30
+ # Where to put generated components. Defaults to `app/components`:
31
+ #
32
+ # config.view_component.generate.path = "lib/components"
33
+ #
35
34
  # #### `#sidecar`
36
35
  #
37
36
  # Always generate a component with a sidecar directory:
@@ -79,71 +78,62 @@ module ViewComponent
79
78
  #
80
79
  # Required when there is more than one path defined in preview_paths.
81
80
  # Defaults to `""`. If this is blank, the generator will use
82
- # `ViewComponent.config.preview_paths` if defined,
81
+ # `ViewComponent.config.previews.paths` if defined,
83
82
  # `"test/components/previews"` otherwise
84
83
  #
85
84
  # #### `#use_component_path_for_rspec_tests`
86
85
  #
87
- # Whether to use the `config.view_component_path` when generating new
86
+ # Whether to use `config.generate.path` when generating new
88
87
  # RSpec component tests:
89
88
  #
90
89
  # config.view_component.generate.use_component_path_for_rspec_tests = true
91
90
  #
92
- # When set to `true`, the generator will use the `view_component_path` to
91
+ # When set to `true`, the generator will use the `path` to
93
92
  # decide where to generate the new RSpec component test.
94
- # For example, if the `view_component_path` is
93
+ # For example, if the `path` is
95
94
  # `app/views/components`, then the generator will create a new spec file
96
95
  # in `spec/views/components/` rather than the default `spec/components/`.
97
96
 
98
- # @!attribute preview_controller
99
- # @return [String]
100
- # The controller used for previewing components.
101
- # Defaults to `ViewComponentsController`.
102
-
103
- # @!attribute preview_route
104
- # @return [String]
105
- # The entry route for component previews.
106
- # Defaults to `"/rails/view_components"`.
97
+ # @!attribute previews
98
+ # @return [ActiveSupport::OrderedOptions]
99
+ # The subset of configuration options relating to previews.
100
+ #
101
+ # #### `#controller`
102
+ #
103
+ # The controller used for previewing components. Defaults to `ViewComponentsController`:
104
+ #
105
+ # config.view_component.previews.controller = "MyPreviewController"
106
+ #
107
+ # #### `#route`
108
+ #
109
+ # The entry route for component previews. Defaults to `/rails/view_components`:
110
+ #
111
+ # config.view_component.previews.route = "/my_previews"
112
+ #
113
+ # #### `#enabled`
114
+ #
115
+ # Whether component previews are enabled. Defaults to `true` in development and test environments:
116
+ #
117
+ # config.view_component.previews.enabled = false
118
+ #
119
+ # #### `#default_layout`
120
+ #
121
+ # A custom default layout used for the previews index page and individual previews. Defaults to `false`:
122
+ #
123
+ # config.view_component.previews.default_layout = false
124
+ #
107
125
 
108
126
  # @!attribute instrumentation_enabled
109
127
  # @return [Boolean]
110
128
  # Whether ActiveSupport notifications are enabled.
111
129
  # Defaults to `false`.
112
130
 
113
- # @!attribute view_component_path
114
- # @return [String]
115
- # The path in which components, their templates, and their sidecars should
116
- # be stored.
117
- # Defaults to `"app/components"`.
118
-
119
- # @!attribute component_parent_class
120
- # @return [String]
121
- # The parent class from which generated components will inherit.
122
- # Defaults to `nil`. If this is falsy, generators will use
123
- # `"ApplicationComponent"` if defined, `"ViewComponent::Base"` otherwise.
124
-
125
- # @!attribute show_previews
126
- # @return [Boolean]
127
- # Whether component previews are enabled.
128
- # Defaults to `true` in development and test environments.
129
-
130
- # @!attribute preview_paths
131
- # @return [Array<String>]
132
- # The locations in which component previews will be looked up.
133
- # Defaults to `['test/components/previews']` relative to your Rails root.
134
-
135
131
  # @!attribute test_controller
136
132
  # @return [String]
137
133
  # The controller used for testing components.
138
134
  # Can also be configured on a per-test basis using `#with_controller_class`.
139
135
  # Defaults to `ApplicationController`.
140
136
 
141
- # @!attribute default_preview_layout
142
- # @return [String]
143
- # A custom default layout used for the previews index page and individual
144
- # previews.
145
- # Defaults to `nil`. If this is falsy, `"component_preview"` is used.
146
-
147
137
  def default_preview_paths
148
138
  (default_rails_preview_paths + default_rails_engines_preview_paths).uniq
149
139
  end
@@ -171,6 +161,17 @@ module ViewComponent
171
161
  def default_generate_options
172
162
  options = ActiveSupport::OrderedOptions.new(false)
173
163
  options.preview_path = ""
164
+ options.path = "app/components"
165
+ options
166
+ end
167
+
168
+ def default_previews_options
169
+ options = ActiveSupport::OrderedOptions.new
170
+ options.controller = "ViewComponentsController"
171
+ options.route = "/rails/view_components"
172
+ options.enabled = Rails.env.development? || Rails.env.test?
173
+ options.default_layout = false
174
+ options.paths = default_preview_paths
174
175
  options
175
176
  end
176
177
  end
@@ -8,28 +8,10 @@ module ViewComponent
8
8
  class Engine < Rails::Engine # :nodoc:
9
9
  config.view_component = ViewComponent::Config.current
10
10
 
11
- if Rails.version.to_f < 8.0
12
- rake_tasks do
13
- load "view_component/rails/tasks/view_component.rake"
14
- end
15
- else
16
- initializer "view_component.stats_directories" do |app|
17
- require "rails/code_statistics"
18
-
19
- if Rails.root.join(ViewComponent::Base.view_component_path).directory?
20
- Rails::CodeStatistics.register_directory("ViewComponents", ViewComponent::Base.view_component_path)
21
- end
22
-
23
- if Rails.root.join("test/components").directory?
24
- Rails::CodeStatistics.register_directory("ViewComponent tests", "test/components", test_directory: true)
25
- end
26
- end
27
- end
28
-
29
11
  initializer "view_component.set_configs" do |app|
30
12
  options = app.config.view_component
31
13
 
32
- %i[generate preview_controller preview_route].each do |config_option|
14
+ %i[generate previews].each do |config_option|
33
15
  options[config_option] ||= ViewComponent::Base.public_send(config_option)
34
16
  end
35
17
  options.instrumentation_enabled = false if options.instrumentation_enabled.nil?
@@ -37,7 +19,7 @@ module ViewComponent
37
19
 
38
20
  if options.show_previews
39
21
  # This is still necessary because when `config.view_component` is declared, `Rails.root` is unspecified.
40
- options.preview_paths << "#{Rails.root}/test/components/previews" if defined?(Rails.root) && Dir.exist?(
22
+ options.previews.paths << "#{Rails.root}/test/components/previews" if defined?(Rails.root) && Dir.exist?(
41
23
  "#{Rails.root}/test/components/previews"
42
24
  )
43
25
  end
@@ -54,8 +36,8 @@ module ViewComponent
54
36
  initializer "view_component.set_autoload_paths" do |app|
55
37
  options = app.config.view_component
56
38
 
57
- if options.show_previews && !options.preview_paths.empty?
58
- paths_to_add = options.preview_paths - ActiveSupport::Dependencies.autoload_paths
39
+ if options.show_previews && !options.previews.paths.empty?
40
+ paths_to_add = options.previews.paths - ActiveSupport::Dependencies.autoload_paths
59
41
  ActiveSupport::Dependencies.autoload_paths.concat(paths_to_add) if paths_to_add.any?
60
42
  end
61
43
  end
@@ -108,17 +90,17 @@ module ViewComponent
108
90
 
109
91
  if options.show_previews
110
92
  app.routes.prepend do
111
- preview_controller = options.preview_controller.sub(/Controller$/, "").underscore
93
+ preview_controller = options.previews.controller.sub(/Controller$/, "").underscore
112
94
 
113
95
  get(
114
- options.preview_route,
96
+ options.previews.route,
115
97
  to: "#{preview_controller}#index",
116
98
  as: :preview_view_components,
117
99
  internal: true
118
100
  )
119
101
 
120
102
  get(
121
- "#{options.preview_route}/*path",
103
+ "#{options.previews.route}/*path",
122
104
  to: "#{preview_controller}#previews",
123
105
  as: :preview_view_component,
124
106
  internal: true
@@ -102,7 +102,7 @@ module ViewComponent # :nodoc:
102
102
  private
103
103
 
104
104
  def preview_paths
105
- Base.preview_paths
105
+ Base.previews.paths
106
106
  end
107
107
  end
108
108
  end
@@ -214,7 +214,8 @@ module ViewComponent
214
214
  # Called by the compiler, as instance methods are not defined when slots are first registered
215
215
  def register_default_slots
216
216
  registered_slots.each do |slot_name, config|
217
- config[:default_method] = instance_methods.find { |method_name| method_name == :"default_#{slot_name}" }
217
+ default_method_name = :"default_#{slot_name}"
218
+ config[:default_method] = instance_methods.find { |method_name| method_name == default_method_name }
218
219
 
219
220
  registered_slots[slot_name] = config
220
221
  end
@@ -73,7 +73,7 @@ module ViewComponent
73
73
  # @param params [Hash] Parameters to be passed to the preview.
74
74
  # @return [Nokogiri::HTML5]
75
75
  def render_preview(name, from: __vc_test_helpers_preview_class, params: {})
76
- previews_controller = __vc_test_helpers_build_controller(Rails.application.config.view_component.preview_controller.constantize)
76
+ previews_controller = __vc_test_helpers_build_controller(Rails.application.config.view_component.previews.controller.constantize)
77
77
 
78
78
  # From what I can tell, it's not possible to overwrite all request parameters
79
79
  # at once, so we set them individually here.
@@ -233,7 +233,20 @@ module ViewComponent
233
233
  #
234
234
  # @return [ActionController::Base]
235
235
  def vc_test_controller
236
- @vc_test_controller ||= __vc_test_helpers_build_controller(Base.test_controller.constantize)
236
+ @vc_test_controller ||= __vc_test_helpers_build_controller(vc_test_controller_class)
237
+ end
238
+
239
+ # Set the controller used by `render_inline`:
240
+ #
241
+ # ```ruby
242
+ # def vc_test_controller_class
243
+ # MyTestController
244
+ # end
245
+ # ```
246
+ def vc_test_controller_class
247
+ return @__vc_test_controller_class if defined?(@__vc_test_controller_class)
248
+
249
+ defined?(ApplicationController) ? ApplicationController : ActionController::Base
237
250
  end
238
251
 
239
252
  # Access the request used by `render_inline`:
@@ -5,7 +5,7 @@ module ViewComponent
5
5
  MAJOR = 4
6
6
  MINOR = 0
7
7
  PATCH = 0
8
- PRE = "alpha4"
8
+ PRE = "alpha6"
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join(".")
11
11
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: view_component
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0.alpha4
4
+ version: 4.0.0.alpha6
5
5
  platform: ruby
6
6
  authors:
7
7
  - ViewComponent Team
@@ -43,412 +43,6 @@ dependencies:
43
43
  - - "~>"
44
44
  - !ruby/object:Gem::Version
45
45
  version: '1'
46
- - !ruby/object:Gem::Dependency
47
- name: allocation_stats
48
- requirement: !ruby/object:Gem::Requirement
49
- requirements:
50
- - - ">="
51
- - !ruby/object:Gem::Version
52
- version: '0'
53
- type: :development
54
- prerelease: false
55
- version_requirements: !ruby/object:Gem::Requirement
56
- requirements:
57
- - - ">="
58
- - !ruby/object:Gem::Version
59
- version: '0'
60
- - !ruby/object:Gem::Dependency
61
- name: appraisal
62
- requirement: !ruby/object:Gem::Requirement
63
- requirements:
64
- - - "~>"
65
- - !ruby/object:Gem::Version
66
- version: '2'
67
- type: :development
68
- prerelease: false
69
- version_requirements: !ruby/object:Gem::Requirement
70
- requirements:
71
- - - "~>"
72
- - !ruby/object:Gem::Version
73
- version: '2'
74
- - !ruby/object:Gem::Dependency
75
- name: benchmark-ips
76
- requirement: !ruby/object:Gem::Requirement
77
- requirements:
78
- - - "~>"
79
- - !ruby/object:Gem::Version
80
- version: '2'
81
- type: :development
82
- prerelease: false
83
- version_requirements: !ruby/object:Gem::Requirement
84
- requirements:
85
- - - "~>"
86
- - !ruby/object:Gem::Version
87
- version: '2'
88
- - !ruby/object:Gem::Dependency
89
- name: better_html
90
- requirement: !ruby/object:Gem::Requirement
91
- requirements:
92
- - - ">="
93
- - !ruby/object:Gem::Version
94
- version: '0'
95
- type: :development
96
- prerelease: false
97
- version_requirements: !ruby/object:Gem::Requirement
98
- requirements:
99
- - - ">="
100
- - !ruby/object:Gem::Version
101
- version: '0'
102
- - !ruby/object:Gem::Dependency
103
- name: bundler
104
- requirement: !ruby/object:Gem::Requirement
105
- requirements:
106
- - - "~>"
107
- - !ruby/object:Gem::Version
108
- version: '2'
109
- type: :development
110
- prerelease: false
111
- version_requirements: !ruby/object:Gem::Requirement
112
- requirements:
113
- - - "~>"
114
- - !ruby/object:Gem::Version
115
- version: '2'
116
- - !ruby/object:Gem::Dependency
117
- name: capybara
118
- requirement: !ruby/object:Gem::Requirement
119
- requirements:
120
- - - "~>"
121
- - !ruby/object:Gem::Version
122
- version: '3'
123
- type: :development
124
- prerelease: false
125
- version_requirements: !ruby/object:Gem::Requirement
126
- requirements:
127
- - - "~>"
128
- - !ruby/object:Gem::Version
129
- version: '3'
130
- - !ruby/object:Gem::Dependency
131
- name: cuprite
132
- requirement: !ruby/object:Gem::Requirement
133
- requirements:
134
- - - ">="
135
- - !ruby/object:Gem::Version
136
- version: '0'
137
- type: :development
138
- prerelease: false
139
- version_requirements: !ruby/object:Gem::Requirement
140
- requirements:
141
- - - ">="
142
- - !ruby/object:Gem::Version
143
- version: '0'
144
- - !ruby/object:Gem::Dependency
145
- name: erb_lint
146
- requirement: !ruby/object:Gem::Requirement
147
- requirements:
148
- - - ">="
149
- - !ruby/object:Gem::Version
150
- version: '0'
151
- type: :development
152
- prerelease: false
153
- version_requirements: !ruby/object:Gem::Requirement
154
- requirements:
155
- - - ">="
156
- - !ruby/object:Gem::Version
157
- version: '0'
158
- - !ruby/object:Gem::Dependency
159
- name: haml
160
- requirement: !ruby/object:Gem::Requirement
161
- requirements:
162
- - - "~>"
163
- - !ruby/object:Gem::Version
164
- version: '6'
165
- type: :development
166
- prerelease: false
167
- version_requirements: !ruby/object:Gem::Requirement
168
- requirements:
169
- - - "~>"
170
- - !ruby/object:Gem::Version
171
- version: '6'
172
- - !ruby/object:Gem::Dependency
173
- name: jbuilder
174
- requirement: !ruby/object:Gem::Requirement
175
- requirements:
176
- - - "~>"
177
- - !ruby/object:Gem::Version
178
- version: '2'
179
- type: :development
180
- prerelease: false
181
- version_requirements: !ruby/object:Gem::Requirement
182
- requirements:
183
- - - "~>"
184
- - !ruby/object:Gem::Version
185
- version: '2'
186
- - !ruby/object:Gem::Dependency
187
- name: m
188
- requirement: !ruby/object:Gem::Requirement
189
- requirements:
190
- - - "~>"
191
- - !ruby/object:Gem::Version
192
- version: '1'
193
- type: :development
194
- prerelease: false
195
- version_requirements: !ruby/object:Gem::Requirement
196
- requirements:
197
- - - "~>"
198
- - !ruby/object:Gem::Version
199
- version: '1'
200
- - !ruby/object:Gem::Dependency
201
- name: method_source
202
- requirement: !ruby/object:Gem::Requirement
203
- requirements:
204
- - - "~>"
205
- - !ruby/object:Gem::Version
206
- version: '1'
207
- type: :development
208
- prerelease: false
209
- version_requirements: !ruby/object:Gem::Requirement
210
- requirements:
211
- - - "~>"
212
- - !ruby/object:Gem::Version
213
- version: '1'
214
- - !ruby/object:Gem::Dependency
215
- name: minitest
216
- requirement: !ruby/object:Gem::Requirement
217
- requirements:
218
- - - "~>"
219
- - !ruby/object:Gem::Version
220
- version: '5'
221
- type: :development
222
- prerelease: false
223
- version_requirements: !ruby/object:Gem::Requirement
224
- requirements:
225
- - - "~>"
226
- - !ruby/object:Gem::Version
227
- version: '5'
228
- - !ruby/object:Gem::Dependency
229
- name: puma
230
- requirement: !ruby/object:Gem::Requirement
231
- requirements:
232
- - - "~>"
233
- - !ruby/object:Gem::Version
234
- version: '6'
235
- type: :development
236
- prerelease: false
237
- version_requirements: !ruby/object:Gem::Requirement
238
- requirements:
239
- - - "~>"
240
- - !ruby/object:Gem::Version
241
- version: '6'
242
- - !ruby/object:Gem::Dependency
243
- name: rake
244
- requirement: !ruby/object:Gem::Requirement
245
- requirements:
246
- - - "~>"
247
- - !ruby/object:Gem::Version
248
- version: '13'
249
- type: :development
250
- prerelease: false
251
- version_requirements: !ruby/object:Gem::Requirement
252
- requirements:
253
- - - "~>"
254
- - !ruby/object:Gem::Version
255
- version: '13'
256
- - !ruby/object:Gem::Dependency
257
- name: redis
258
- requirement: !ruby/object:Gem::Requirement
259
- requirements:
260
- - - ">="
261
- - !ruby/object:Gem::Version
262
- version: '0'
263
- type: :development
264
- prerelease: false
265
- version_requirements: !ruby/object:Gem::Requirement
266
- requirements:
267
- - - ">="
268
- - !ruby/object:Gem::Version
269
- version: '0'
270
- - !ruby/object:Gem::Dependency
271
- name: rspec-rails
272
- requirement: !ruby/object:Gem::Requirement
273
- requirements:
274
- - - "~>"
275
- - !ruby/object:Gem::Version
276
- version: '7'
277
- type: :development
278
- prerelease: false
279
- version_requirements: !ruby/object:Gem::Requirement
280
- requirements:
281
- - - "~>"
282
- - !ruby/object:Gem::Version
283
- version: '7'
284
- - !ruby/object:Gem::Dependency
285
- name: rubocop-md
286
- requirement: !ruby/object:Gem::Requirement
287
- requirements:
288
- - - "~>"
289
- - !ruby/object:Gem::Version
290
- version: '2'
291
- type: :development
292
- prerelease: false
293
- version_requirements: !ruby/object:Gem::Requirement
294
- requirements:
295
- - - "~>"
296
- - !ruby/object:Gem::Version
297
- version: '2'
298
- - !ruby/object:Gem::Dependency
299
- name: selenium-webdriver
300
- requirement: !ruby/object:Gem::Requirement
301
- requirements:
302
- - - "~>"
303
- - !ruby/object:Gem::Version
304
- version: '4'
305
- type: :development
306
- prerelease: false
307
- version_requirements: !ruby/object:Gem::Requirement
308
- requirements:
309
- - - "~>"
310
- - !ruby/object:Gem::Version
311
- version: '4'
312
- - !ruby/object:Gem::Dependency
313
- name: simplecov-console
314
- requirement: !ruby/object:Gem::Requirement
315
- requirements:
316
- - - "<"
317
- - !ruby/object:Gem::Version
318
- version: '1'
319
- type: :development
320
- prerelease: false
321
- version_requirements: !ruby/object:Gem::Requirement
322
- requirements:
323
- - - "<"
324
- - !ruby/object:Gem::Version
325
- version: '1'
326
- - !ruby/object:Gem::Dependency
327
- name: simplecov
328
- requirement: !ruby/object:Gem::Requirement
329
- requirements:
330
- - - "<"
331
- - !ruby/object:Gem::Version
332
- version: '1'
333
- type: :development
334
- prerelease: false
335
- version_requirements: !ruby/object:Gem::Requirement
336
- requirements:
337
- - - "<"
338
- - !ruby/object:Gem::Version
339
- version: '1'
340
- - !ruby/object:Gem::Dependency
341
- name: slim
342
- requirement: !ruby/object:Gem::Requirement
343
- requirements:
344
- - - "~>"
345
- - !ruby/object:Gem::Version
346
- version: '5'
347
- type: :development
348
- prerelease: false
349
- version_requirements: !ruby/object:Gem::Requirement
350
- requirements:
351
- - - "~>"
352
- - !ruby/object:Gem::Version
353
- version: '5'
354
- - !ruby/object:Gem::Dependency
355
- name: sprockets-rails
356
- requirement: !ruby/object:Gem::Requirement
357
- requirements:
358
- - - "~>"
359
- - !ruby/object:Gem::Version
360
- version: '3'
361
- type: :development
362
- prerelease: false
363
- version_requirements: !ruby/object:Gem::Requirement
364
- requirements:
365
- - - "~>"
366
- - !ruby/object:Gem::Version
367
- version: '3'
368
- - !ruby/object:Gem::Dependency
369
- name: standard
370
- requirement: !ruby/object:Gem::Requirement
371
- requirements:
372
- - - "~>"
373
- - !ruby/object:Gem::Version
374
- version: '1'
375
- type: :development
376
- prerelease: false
377
- version_requirements: !ruby/object:Gem::Requirement
378
- requirements:
379
- - - "~>"
380
- - !ruby/object:Gem::Version
381
- version: '1'
382
- - !ruby/object:Gem::Dependency
383
- name: turbo-rails
384
- requirement: !ruby/object:Gem::Requirement
385
- requirements:
386
- - - "~>"
387
- - !ruby/object:Gem::Version
388
- version: '2'
389
- type: :development
390
- prerelease: false
391
- version_requirements: !ruby/object:Gem::Requirement
392
- requirements:
393
- - - "~>"
394
- - !ruby/object:Gem::Version
395
- version: '2'
396
- - !ruby/object:Gem::Dependency
397
- name: warning
398
- requirement: !ruby/object:Gem::Requirement
399
- requirements:
400
- - - ">="
401
- - !ruby/object:Gem::Version
402
- version: '0'
403
- type: :development
404
- prerelease: false
405
- version_requirements: !ruby/object:Gem::Requirement
406
- requirements:
407
- - - ">="
408
- - !ruby/object:Gem::Version
409
- version: '0'
410
- - !ruby/object:Gem::Dependency
411
- name: yard-activesupport-concern
412
- requirement: !ruby/object:Gem::Requirement
413
- requirements:
414
- - - "<"
415
- - !ruby/object:Gem::Version
416
- version: '1'
417
- type: :development
418
- prerelease: false
419
- version_requirements: !ruby/object:Gem::Requirement
420
- requirements:
421
- - - "<"
422
- - !ruby/object:Gem::Version
423
- version: '1'
424
- - !ruby/object:Gem::Dependency
425
- name: yard
426
- requirement: !ruby/object:Gem::Requirement
427
- requirements:
428
- - - "<"
429
- - !ruby/object:Gem::Version
430
- version: '1'
431
- type: :development
432
- prerelease: false
433
- version_requirements: !ruby/object:Gem::Requirement
434
- requirements:
435
- - - "<"
436
- - !ruby/object:Gem::Version
437
- version: '1'
438
- - !ruby/object:Gem::Dependency
439
- name: propshaft
440
- requirement: !ruby/object:Gem::Requirement
441
- requirements:
442
- - - "~>"
443
- - !ruby/object:Gem::Version
444
- version: '1'
445
- type: :development
446
- prerelease: false
447
- version_requirements: !ruby/object:Gem::Requirement
448
- requirements:
449
- - - "~>"
450
- - !ruby/object:Gem::Version
451
- version: '1'
452
46
  executables: []
453
47
  extensions: []
454
48
  extra_rdoc_files: []
@@ -469,7 +63,6 @@ files:
469
63
  - lib/view_component/collection.rb
470
64
  - lib/view_component/compile_cache.rb
471
65
  - lib/view_component/compiler.rb
472
- - lib/view_component/component_local_config.rb
473
66
  - lib/view_component/config.rb
474
67
  - lib/view_component/configurable.rb
475
68
  - lib/view_component/deprecation.rb
@@ -1,60 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ViewComponent
4
- module ComponentLocalConfig
5
- class Configuration
6
- def self.defaults
7
- ActiveSupport::Configurable::Configuration[
8
- strip_trailing_whitespace: false
9
- ]
10
- end
11
-
12
- def initialize(config = defaults)
13
- @config = config
14
- end
15
-
16
- delegate_missing_to :@config
17
-
18
- def inheritable_copy
19
- self.class.new(@config.inheritable_copy)
20
- end
21
-
22
- private
23
-
24
- delegate :defaults, to: :class
25
- end
26
-
27
- extend ActiveSupport::Concern
28
-
29
- included do
30
- # :nocov:
31
- def view_component_config
32
- @__vc_config ||= self.class.view_component_config.inheritable_copy
33
- end
34
-
35
- private
36
-
37
- def inherited(child)
38
- child.instance_variable_set(:@__vc_config, nil)
39
- super
40
- end
41
- # :nocov:
42
- end
43
-
44
- class_methods do
45
- def view_component_config
46
- @__vc_config ||= if respond_to?(:superclass) && superclass.respond_to?(:view_component_config)
47
- superclass.view_component_config.inheritable_copy
48
- else
49
- # create a new "anonymous" class that will host the compiled reader methods
50
- ViewComponent::ComponentLocalConfig::Configuration.new
51
- end
52
- end
53
-
54
- def configure_view_component(&block)
55
- view_component_config.instance_eval(&block)
56
- view_component_config.compile_methods!
57
- end
58
- end
59
- end
60
- end