view_component 4.5.0 → 4.7.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 +28 -0
- data/lib/view_component/base.rb +2 -1
- data/lib/view_component/instrumentation.rb +18 -5
- data/lib/view_component/preview.rb +1 -1
- data/lib/view_component/template.rb +7 -0
- data/lib/view_component/version.rb +1 -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: cc884d47517a4f27d0159acd6e744d31a51b29217e3c5e38d9db9594bc25bc79
|
|
4
|
+
data.tar.gz: 0ca9efab88b736c678177eab1edd7165365519724c9efe4b7071391f605707b8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 23fee96c0259c1a245132a138edf4233fdc228aafb4807ce62f746796295a870548420cb73f99e5ff6705d536e4cfeb6128fe87135c122741a54e8235cba9a31
|
|
7
|
+
data.tar.gz: ca9c6a5d1af51e689d8ec17d91aa06f8cfb25781eb6b77702ecb74639778d0b7d0842f14aaed51243bc4a373329f17bf66beb2efa9d0bb7fb7ced7880d4d8878
|
data/docs/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,34 @@ nav_order: 6
|
|
|
10
10
|
|
|
11
11
|
## main
|
|
12
12
|
|
|
13
|
+
## 4.7.0
|
|
14
|
+
|
|
15
|
+
* Fix stale content cache when slots are accessed before `render_in`.
|
|
16
|
+
|
|
17
|
+
*Jared Armstrong*
|
|
18
|
+
|
|
19
|
+
* Add rubocop-view_component to resources.
|
|
20
|
+
|
|
21
|
+
*Andy Waite*
|
|
22
|
+
|
|
23
|
+
* Fix bug where inheritance of components with formatless templates improperly raised a NoMethodError.
|
|
24
|
+
|
|
25
|
+
*GitHub Copilot*, *Joel Hawksley*, *Cameron Dutro*
|
|
26
|
+
|
|
27
|
+
## 4.6.0
|
|
28
|
+
|
|
29
|
+
* 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`.
|
|
30
|
+
|
|
31
|
+
*GitHub Copilot*
|
|
32
|
+
|
|
33
|
+
* Replace deprecated `require_dependency` with `require` in preview loading.
|
|
34
|
+
|
|
35
|
+
*GitHub Copilot*
|
|
36
|
+
|
|
37
|
+
* Return `html_safe` empty string from `render_in` when `render?` is false.
|
|
38
|
+
|
|
39
|
+
*GitHub Copilot*
|
|
40
|
+
|
|
13
41
|
## 4.5.0
|
|
14
42
|
|
|
15
43
|
* Fix initialization ordering issue causing missing asset errors in Sprockets.
|
data/lib/view_component/base.rb
CHANGED
|
@@ -131,6 +131,7 @@ module ViewComponent
|
|
|
131
131
|
end
|
|
132
132
|
|
|
133
133
|
@__vc_content_evaluated = false
|
|
134
|
+
remove_instance_variable(:@__vc_content) if defined?(@__vc_content)
|
|
134
135
|
@__vc_render_in_block = block
|
|
135
136
|
@view_context.instance_variable_set(:@virtual_path, virtual_path)
|
|
136
137
|
|
|
@@ -160,7 +161,7 @@ module ViewComponent
|
|
|
160
161
|
|
|
161
162
|
value
|
|
162
163
|
else
|
|
163
|
-
""
|
|
164
|
+
"".html_safe
|
|
164
165
|
end
|
|
165
166
|
ensure
|
|
166
167
|
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|
|
|
98
|
+
Dir["#{preview_path}/**/*preview.rb"].sort.each { |file| require file }
|
|
99
99
|
end
|
|
100
100
|
end
|
|
101
101
|
|
|
@@ -21,6 +21,13 @@ module ViewComponent
|
|
|
21
21
|
|
|
22
22
|
class File < Template
|
|
23
23
|
def initialize(component:, details:, path:)
|
|
24
|
+
# If the template file has no format (e.g. .erb instead of .html.erb),
|
|
25
|
+
# assume the default format (html).
|
|
26
|
+
if details.format.nil?
|
|
27
|
+
Kernel.warn("WARNING: Template format for #{path} is missing, defaulting to :html.")
|
|
28
|
+
details = ActionView::TemplateDetails.new(details.locale, details.handler, DEFAULT_FORMAT, details.variant)
|
|
29
|
+
end
|
|
30
|
+
|
|
24
31
|
@strip_annotation_line = false
|
|
25
32
|
|
|
26
33
|
# Rails 8.1 added a newline to compiled ERB output (rails/rails#53731).
|
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.
|
|
4
|
+
version: 4.7.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.
|
|
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.
|