view_component 4.5.0 → 4.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9bb24a0e61e0b08097feff53e3303b5961b3c7bf24a8cc81b9a70480e7a7bfea
4
- data.tar.gz: 7ba2ec6ff0f9ecaaf391c9218c86ebdbba78ac5cdee29d76c6f5367dc4fc7840
3
+ metadata.gz: 761d9451b4af2b617182339d3a356985d119be9ff490018815d9affd6ede89dc
4
+ data.tar.gz: 508b8e0699e11bbed4f649cebc9df0015e08e45b1cf92c1c528f13d566422c79
5
5
  SHA512:
6
- metadata.gz: ef478e3d1270858f2d08fcfafee488c1c6899d9f80f7dcf0827f024519b60a366128e09ca308032d98a2087e993a6d6d4b36f5b8406d9fecb6baf05619ef72e9
7
- data.tar.gz: 17f0d08421581f0f1b584debb484626b66f821317ff32d573dc2f52649a2cf6a82d911caec0bbb2362ee42bb9d99550c0857ebea42b0011b366f86149f1ec125
6
+ metadata.gz: 4820e68ab750d1c89901c2244527e8896d42a270afb20d8add4c0437fab80d7f4623e9da3817baafda390d94c77c0d5e79959f95772fedc571b132565fcd8bca
7
+ data.tar.gz: 1a3118de2ce98910b40ba370b13618083c396565a7b2db128eea39de7263c2d17240865caf2f94c7e83ee9113537cd5d18f6b6c3c80e137d5f5e15f1f823ba17
data/docs/CHANGELOG.md CHANGED
@@ -10,6 +10,20 @@ nav_order: 6
10
10
 
11
11
  ## main
12
12
 
13
+ ## 4.6.0
14
+
15
+ * Add `view_identifier` to the `render.view_component` instrumentation event payload, containing the path to the component's template file (e.g. `app/components/my_component.html.erb`). For components using inline render methods, `view_identifier` will be `nil`.
16
+
17
+ *GitHub Copilot*
18
+
19
+ * Replace deprecated `require_dependency` with `require` in preview loading.
20
+
21
+ *GitHub Copilot*
22
+
23
+ * Return `html_safe` empty string from `render_in` when `render?` is false.
24
+
25
+ *Copilot*
26
+
13
27
  ## 4.5.0
14
28
 
15
29
  * Fix initialization ordering issue causing missing asset errors in Sprockets.
@@ -160,7 +160,7 @@ module ViewComponent
160
160
 
161
161
  value
162
162
  else
163
- ""
163
+ "".html_safe
164
164
  end
165
165
  ensure
166
166
  view_context.instance_variable_set(:@virtual_path, @old_virtual_path)
@@ -11,15 +11,28 @@ module ViewComponent # :nodoc:
11
11
  def render_in(view_context, &block)
12
12
  return super if !Rails.application.config.view_component.instrumentation_enabled.present?
13
13
 
14
+ payload = {
15
+ name: self.class.name,
16
+ identifier: self.class.identifier,
17
+ view_identifier: nil
18
+ }
19
+
14
20
  ActiveSupport::Notifications.instrument(
15
21
  "render.view_component",
16
- {
17
- name: self.class.name,
18
- identifier: self.class.identifier
19
- }
22
+ payload
20
23
  ) do
21
- super
24
+ result = super
25
+ payload[:view_identifier] = @__vc_instrumentation_view_identifier
26
+ result
22
27
  end
28
+ ensure
29
+ @__vc_instrumentation_view_identifier = nil
30
+ end
31
+
32
+ def around_render
33
+ result = super
34
+ @__vc_instrumentation_view_identifier = current_template&.path
35
+ result
23
36
  end
24
37
  end
25
38
  end
@@ -95,7 +95,7 @@ module ViewComponent # :nodoc:
95
95
  # @private
96
96
  def __vc_load_previews
97
97
  Array(preview_paths).each do |preview_path|
98
- Dir["#{preview_path}/**/*preview.rb"].sort.each { |file| require_dependency file }
98
+ Dir["#{preview_path}/**/*preview.rb"].sort.each { |file| require file }
99
99
  end
100
100
  end
101
101
 
@@ -3,7 +3,7 @@
3
3
  module ViewComponent
4
4
  module VERSION
5
5
  MAJOR = 4
6
- MINOR = 5
6
+ MINOR = 6
7
7
  PATCH = 0
8
8
  PRE = nil
9
9
 
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.5.0
4
+ version: 4.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ViewComponent Team
@@ -135,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
135
  - !ruby/object:Gem::Version
136
136
  version: '0'
137
137
  requirements: []
138
- rubygems_version: 4.0.3
138
+ rubygems_version: 4.0.6
139
139
  specification_version: 4
140
140
  summary: A framework for building reusable, testable & encapsulated view components
141
141
  in Ruby on Rails.