view_component 2.54.1 → 2.55.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: f9cab3c05c054f173b248b903912dfb432eeec09b2d3d42f6fd602a7565acd2d
4
- data.tar.gz: 78b70e8ea1306fb635978dbe2a86cece2618247bb0079798e5a886f2210dfed1
3
+ metadata.gz: c6460c94f3bb4f2b19cd5311d957d2187e437276c0c19b657834cccba39fb36f
4
+ data.tar.gz: c0dfc55481d2bcfcdc2f54ea4f4bacc94780e2dce39b77eaf5828490c1d0fc52
5
5
  SHA512:
6
- metadata.gz: 653d1c627f3fb52677e47516472fec508c562359e3beac3defa43d172d3e793359207df638f352f1c1cc6a876a0f3c3fdc4c7ff4eefdc1907c20a161e9359d83
7
- data.tar.gz: 25bc7a21cde84c3311d9482cdb2ccccf821ce2c104492506a999e81f8cd9d9a5b3b3c19f3b417dc3f250787adf18fbe9f9d9ff5589e897fc199e26e50e4b0efa
6
+ metadata.gz: 6ffed42bf70668cf3dbf811f5f24e4a9e2e6cca7fdaea3674f8323c08a60b0f7c49f94c9a1d0bb1c962fb04c0c6dbdb219891116b70385bb8d3fe5f650d86f91
7
+ data.tar.gz: 416501060d316e680dbf7f65543aa9a57b693e13bf8a9ebd8c244794155b33702863b22723d140bb85df560e4b18d746f3d534a9a98f4698ced8435cecce3375
data/docs/CHANGELOG.md CHANGED
@@ -9,6 +9,24 @@ title: Changelog
9
9
 
10
10
  ## main
11
11
 
12
+ ## 2.55.0
13
+
14
+ * Add `render_parent` convenience method to avoid confusion between `<%= super %>` and `<% super %>` in template code.
15
+
16
+ *Cameron Dutro*
17
+
18
+ * Add note about discouraging inheritance.
19
+
20
+ *Joel Hawksley*
21
+
22
+ * Clean up grammar in documentation.
23
+
24
+ *Joel Hawksley*
25
+
26
+ * The ViewComponent team at GitHub is hiring! We're looking for a Rails engineer with accessibility experience: [https://boards.greenhouse.io/github/jobs/4020166](https://boards.greenhouse.io/github/jobs/4020166). Reach out to joelhawksley@github.com with any questions!
27
+
28
+ * The ViewComponent team is hosting a happy hour at RailsConf. Join us for snacks, drinks, and stickers: [https://www.eventbrite.com/e/viewcomponent-happy-hour-tickets-304168585427](https://www.eventbrite.com/e/viewcomponent-happy-hour-tickets-304168585427)
29
+
12
30
  ## 2.54.1
13
31
 
14
32
  * Update docs dependencies.
@@ -26,7 +44,7 @@ title: Changelog
26
44
 
27
45
  *Blake Williams*
28
46
 
29
- * Add QuickNode to list of companies that heavily rely on ViewComponent.
47
+ * Add QuickNode to list of companies that use ViewComponent.
30
48
 
31
49
  *Luc Castera*
32
50
 
@@ -60,7 +78,7 @@ title: Changelog
60
78
 
61
79
  *Jason Swett*
62
80
 
63
- * Add Bearer to list of companies that heavily rely on ViewComponent.
81
+ * Add Bearer to list of companies that use ViewComponent.
64
82
 
65
83
  *Yaroslav Shmarov*
66
84
 
@@ -68,6 +86,10 @@ title: Changelog
68
86
 
69
87
  *Joel Hawksley*
70
88
 
89
+ * Enable rendering arbitrary block contents in the view context in tests.
90
+
91
+ *Cameron Dutro*
92
+
71
93
  ## 2.52.0
72
94
 
73
95
  * Add ADR for separate slot getter/setter API.
@@ -117,6 +117,20 @@ module ViewComponent
117
117
  render_template_for(@__vc_variant).to_s + _output_postamble
118
118
  end
119
119
 
120
+ # Subclass components that call `super` inside their template code will cause a
121
+ # double render if they accidentally emit the result:
122
+ #
123
+ # <%= super %> # double-renders
124
+ #
125
+ # <% super %> # does not double-render
126
+ #
127
+ # Calls `super`, returning nil to avoid rendering the result twice.
128
+ def render_parent
129
+ mtd = @__vc_variant ? "call_#{@__vc_variant}" : "call"
130
+ method(mtd).super_method.call
131
+ nil
132
+ end
133
+
120
134
  # :nocov:
121
135
  def render_template_for(variant = nil)
122
136
  # Force compilation here so the compiler always redefines render_template_for.
@@ -19,8 +19,8 @@ module ViewComponent
19
19
  # :nocov:
20
20
  if ENV["DEBUG"]
21
21
  warn(
22
- "WARNING in `ViewComponent::TestHelpers`: You must add `capybara` " \
23
- "to your Gemfile to use Capybara assertions."
22
+ "WARNING in `ViewComponent::TestHelpers`: Add `capybara` " \
23
+ "to Gemfile to use Capybara assertions."
24
24
  )
25
25
  end
26
26
 
@@ -51,6 +51,21 @@ module ViewComponent
51
51
  Nokogiri::HTML.fragment(@rendered_component)
52
52
  end
53
53
 
54
+ # Execute the given block in the view context. Internally sets `page` to be a
55
+ # `Capybara::Node::Simple`, allowing for Capybara assertions to be used:
56
+ #
57
+ # ```ruby
58
+ # render_in_view_context do
59
+ # render(MyComponent.new)
60
+ # end
61
+ #
62
+ # assert_text("Hello, World!")
63
+ # ```
64
+ def render_in_view_context(&block)
65
+ @rendered_component = controller.view_context.instance_exec(&block)
66
+ Nokogiri::HTML.fragment(@rendered_component)
67
+ end
68
+
54
69
  # @private
55
70
  def controller
56
71
  @controller ||= build_controller(Base.test_controller.constantize)
@@ -3,8 +3,8 @@
3
3
  module ViewComponent
4
4
  module VERSION
5
5
  MAJOR = 2
6
- MINOR = 54
7
- PATCH = 1
6
+ MINOR = 55
7
+ PATCH = 0
8
8
 
9
9
  STRING = [MAJOR, MINOR, PATCH].join(".")
10
10
  end
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.54.1
4
+ version: 2.55.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitHub Open Source
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-11 00:00:00.000000000 Z
11
+ date: 2022-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport