view_component 4.6.0 → 4.8.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: 761d9451b4af2b617182339d3a356985d119be9ff490018815d9affd6ede89dc
4
- data.tar.gz: 508b8e0699e11bbed4f649cebc9df0015e08e45b1cf92c1c528f13d566422c79
3
+ metadata.gz: 0cd32d6d38604882019810f1213145bafb749c66b57d4edcee32902092f436ab
4
+ data.tar.gz: c29d17a4f72223b7e342e5f224fc39505d3bc50cb1a8174db6371c6d6b8ded6b
5
5
  SHA512:
6
- metadata.gz: 4820e68ab750d1c89901c2244527e8896d42a270afb20d8add4c0437fab80d7f4623e9da3817baafda390d94c77c0d5e79959f95772fedc571b132565fcd8bca
7
- data.tar.gz: 1a3118de2ce98910b40ba370b13618083c396565a7b2db128eea39de7263c2d17240865caf2f94c7e83ee9113537cd5d18f6b6c3c80e137d5f5e15f1f823ba17
6
+ metadata.gz: aecaee657c788ae3395994d2234711101fc58f5439f9488993e9b928cb103abba5f5add66d53719259c4f6069a661b7e0a2c3a96ce3c990ca1191fa92b2933fd
7
+ data.tar.gz: 87688cbcfeb6a50be556a435b97e0ff6541fdb4383589b24971c7a6c0caee61d506acee766da36b76345d780cdb0877a6ebff3fb4965c1cb7d1b2878f65e4aab
data/docs/CHANGELOG.md CHANGED
@@ -10,6 +10,26 @@ nav_order: 6
10
10
 
11
11
  ## main
12
12
 
13
+ ## 4.8.0
14
+
15
+ * Add `compile.view_component` ActiveSupport::Notifications event for eager compilation at boot time.
16
+
17
+ *Joel Hawksley*, *GitHub Copilot*
18
+
19
+ ## 4.7.0
20
+
21
+ * Fix stale content cache when slots are accessed before `render_in`.
22
+
23
+ *Jared Armstrong*
24
+
25
+ * Add rubocop-view_component to resources.
26
+
27
+ *Andy Waite*
28
+
29
+ * Fix bug where inheritance of components with formatless templates improperly raised a NoMethodError.
30
+
31
+ *GitHub Copilot*, *Joel Hawksley*, *Cameron Dutro*
32
+
13
33
  ## 4.6.0
14
34
 
15
35
  * 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`.
@@ -22,7 +42,7 @@ nav_order: 6
22
42
 
23
43
  * Return `html_safe` empty string from `render_in` when `render?` is false.
24
44
 
25
- *Copilot*
45
+ *GitHub Copilot*
26
46
 
27
47
  ## 4.5.0
28
48
 
@@ -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
 
@@ -517,6 +518,7 @@ module ViewComponent
517
518
  # @param extensions [Array<String>] Extensions of which to return matching sidecar files.
518
519
  def sidecar_files(extensions)
519
520
  return [] unless identifier
521
+ return [] unless name
520
522
 
521
523
  extensions = extensions.join(",")
522
524
 
@@ -79,7 +79,11 @@ module ViewComponent
79
79
 
80
80
  initializer "view_component.eager_load_actions" do
81
81
  ActiveSupport.on_load(:after_initialize) do
82
- ViewComponent::Base.descendants.each(&:__vc_compile) if Rails.application.config.eager_load
82
+ if Rails.application.config.eager_load
83
+ ActiveSupport::Notifications.instrument("compile.view_component") do
84
+ ViewComponent::Base.descendants.each(&:__vc_compile)
85
+ end
86
+ end
83
87
  end
84
88
  end
85
89
 
@@ -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).
@@ -3,7 +3,7 @@
3
3
  module ViewComponent
4
4
  module VERSION
5
5
  MAJOR = 4
6
- MINOR = 6
6
+ MINOR = 8
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.6.0
4
+ version: 4.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ViewComponent Team