view_component 2.80.0 → 2.82.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of view_component might be problematic. Click here for more details.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9bb20706245c43b9c5fa4d11087a2e98332bda53d659f7065874a3c0b8545547
|
4
|
+
data.tar.gz: 13821a1e91da8a8dce8270962b99aa3b84fddb9731f99c2e2acfd143ad017836
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b0ebf7ac54fc2c82374b29f9cceadfe55af73516ad2e4c65dad69cd65a7c63de3e00ef9cdba8b359c1061309f9a0d2f90344374feec2b37211fbfb36282c96b
|
7
|
+
data.tar.gz: 48e156dcc5fa1ac9a6cff64e4cb585d528103452938a515d1e3598b505b03188e89362c393c86c0a05437f9a8c28f22e937e3d706f3da17ae03a7c1371728505
|
@@ -1,8 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
class ViewComponentsSystemTestController < Rails::ApplicationController # :nodoc:
|
3
|
+
class ViewComponentsSystemTestController < ActionController::Base # :nodoc:
|
6
4
|
def system_test_entrypoint
|
7
5
|
render file: "./tmp/view_components/#{params.permit(:file)[:file]}"
|
8
6
|
end
|
data/docs/CHANGELOG.md
CHANGED
@@ -10,6 +10,30 @@ nav_order: 5
|
|
10
10
|
|
11
11
|
## main
|
12
12
|
|
13
|
+
## 2.82.0
|
14
|
+
|
15
|
+
* Revert "Avoid loading ActionView::Base during initialization (#1528)"
|
16
|
+
|
17
|
+
*Jon Rohan*
|
18
|
+
|
19
|
+
* Fix tests using `with_rendered_component_path` with custom layouts.
|
20
|
+
|
21
|
+
*Ian Hollander*
|
22
|
+
|
23
|
+
## 2.81.0
|
24
|
+
|
25
|
+
* Adjust the way response objects are set on the preview controller to work around a recent change in Rails main.
|
26
|
+
|
27
|
+
*Cameron Dutro*
|
28
|
+
|
29
|
+
* Fix typo in "Generate a Stimulus controller" documentation.
|
30
|
+
|
31
|
+
*Ben Trewern*
|
32
|
+
|
33
|
+
* Modify the `render_in_view_context` test helper to forward its args to the block.
|
34
|
+
|
35
|
+
*Cameron Dutro*
|
36
|
+
|
13
37
|
## 2.80.0
|
14
38
|
|
15
39
|
* Move system test endpoint out of the unrelated previews controller.
|
data/lib/view_component/base.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "rails"
|
4
|
-
require "view_component/
|
4
|
+
require "view_component/base"
|
5
5
|
|
6
6
|
module ViewComponent
|
7
7
|
class Engine < Rails::Engine # :nodoc:
|
8
|
-
config.view_component = ViewComponent::
|
8
|
+
config.view_component = ViewComponent::Base.config
|
9
9
|
|
10
10
|
rake_tasks do
|
11
11
|
load "view_component/rails/tasks/view_component.rake"
|
@@ -14,6 +14,9 @@ module ViewComponent
|
|
14
14
|
initializer "view_component.set_configs" do |app|
|
15
15
|
options = app.config.view_component
|
16
16
|
|
17
|
+
%i[generate preview_controller preview_route show_previews_source].each do |config_option|
|
18
|
+
options[config_option] ||= ViewComponent::Base.public_send(config_option)
|
19
|
+
end
|
17
20
|
options.instrumentation_enabled = false if options.instrumentation_enabled.nil?
|
18
21
|
options.render_monkey_patch_enabled = true if options.render_monkey_patch_enabled.nil?
|
19
22
|
options.show_previews = (Rails.env.development? || Rails.env.test?) if options.show_previews.nil?
|
@@ -36,8 +39,6 @@ module ViewComponent
|
|
36
39
|
|
37
40
|
initializer "view_component.enable_instrumentation" do |app|
|
38
41
|
ActiveSupport.on_load(:view_component) do
|
39
|
-
Base.config = app.config.view_component
|
40
|
-
|
41
42
|
if app.config.view_component.instrumentation_enabled.present?
|
42
43
|
# :nocov:
|
43
44
|
ViewComponent::Base.prepend(ViewComponent::Instrumentation)
|
@@ -91,7 +91,7 @@ module ViewComponent
|
|
91
91
|
end
|
92
92
|
|
93
93
|
previews_controller.request.params[:path] = "#{from.preview_name}/#{name}"
|
94
|
-
previews_controller.
|
94
|
+
previews_controller.set_response!(ActionDispatch::Response.new)
|
95
95
|
result = previews_controller.previews
|
96
96
|
|
97
97
|
@rendered_content = result
|
@@ -99,21 +99,23 @@ module ViewComponent
|
|
99
99
|
Nokogiri::HTML.fragment(@rendered_content)
|
100
100
|
end
|
101
101
|
|
102
|
-
# Execute the given block in the view context
|
103
|
-
# `Capybara::Node::Simple`, allowing for
|
102
|
+
# Execute the given block in the view context (using `instance_exec`).
|
103
|
+
# Internally sets `page` to be a `Capybara::Node::Simple`, allowing for
|
104
|
+
# Capybara assertions to be used. All arguments are forwarded to the block.
|
104
105
|
#
|
105
106
|
# ```ruby
|
106
|
-
# render_in_view_context do
|
107
|
-
# render(MyComponent.new)
|
107
|
+
# render_in_view_context(arg1, arg2:) do |arg1, arg2:|
|
108
|
+
# render(MyComponent.new(arg1, arg2))
|
108
109
|
# end
|
109
110
|
#
|
110
111
|
# assert_text("Hello, World!")
|
111
112
|
# ```
|
112
|
-
def render_in_view_context(&block)
|
113
|
+
def render_in_view_context(*args, &block)
|
113
114
|
@page = nil
|
114
|
-
@rendered_content = controller.view_context.instance_exec(&block)
|
115
|
+
@rendered_content = controller.view_context.instance_exec(*args, &block)
|
115
116
|
Nokogiri::HTML.fragment(@rendered_content)
|
116
117
|
end
|
118
|
+
ruby2_keywords(:render_in_view_context) if respond_to?(:ruby2_keywords, true)
|
117
119
|
|
118
120
|
# @private
|
119
121
|
def controller
|
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.82.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ViewComponent Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|