We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
capture
nil
1 parent ea5b98d commit 07bccc3Copy full SHA for 07bccc3
lib/phlex/rails/sgml/state.rb
@@ -17,7 +17,7 @@ def capture
17
ensure
18
@capturing = original_capturing
19
@fragments = original_fragments
20
- end
+ end || ""
21
else
22
super
23
end
test/capture.test.rb
@@ -0,0 +1,22 @@
1
+# frozen_string_literal: true
2
+
3
+class Component < Phlex::HTML
4
+ def view_template
5
+ yield if block_given?
6
+ end
7
+end
8
9
+UNSET = Object.new.freeze
10
11
+test "capturing nothing returns an empty string" do
12
+ output = UNSET
13
+ view_context = ActionController::Base.new.view_context
14
15
+ Component.render_in(view_context) do |c|
16
+ output = c.capture do
+ # Intentionally empty to capture nothing
+ assert_equal "", output
0 commit comments