@@ -18,28 +18,38 @@ def helpers
18
18
end
19
19
end
20
20
21
- def render ( *args , **, &block )
21
+ def render ( *args , **kwargs , &block )
22
22
renderable = args [ 0 ]
23
23
24
24
case renderable
25
- when Phlex ::SGML , Proc , Method
25
+ when Phlex ::SGML , Proc , Method , String
26
26
return super
27
27
when Class
28
28
return super if renderable < Phlex ::SGML
29
29
when Enumerable
30
30
return super unless ActiveRecord ::Relation === renderable
31
- else
32
- if block
33
- @_context . target << @_view_context . render ( *args , **) do |*yielded_args |
34
- if yielded_args . length == 1 && defined? ( ViewComponent ::Base ) && ViewComponent ::Base === yielded_args [ 0 ]
35
- capture ( Phlex ::Rails ::Buffered . new ( yielded_args [ 0 ] , view : self ) , &block )
36
- else
37
- capture ( *yielded_args , &block )
38
- end
31
+ when nil
32
+ partial = kwargs . delete ( :partial )
33
+
34
+ if partial # this is a hack to get around https://github.com/rails/rails/issues/51015
35
+ @_context . target << @_view_context . render ( partial , **kwargs ) do |*yielded_args |
36
+ capture ( *yielded_args , &block )
37
+ end
38
+
39
+ return nil
40
+ end
41
+ end
42
+
43
+ if block
44
+ @_context . target << @_view_context . render ( *args , **kwargs ) do |*yielded_args |
45
+ if yielded_args . length == 1 && defined? ( ViewComponent ::Base ) && ViewComponent ::Base === yielded_args [ 0 ]
46
+ capture ( Phlex ::Rails ::Buffered . new ( yielded_args [ 0 ] , view : self ) , &block )
47
+ else
48
+ capture ( *yielded_args , &block )
39
49
end
40
- else
41
- @_context . target << @_view_context . render ( *args , **)
42
50
end
51
+ else
52
+ @_context . target << @_view_context . render ( *args , **kwargs )
43
53
end
44
54
45
55
nil
@@ -81,28 +91,6 @@ def capture(...)
81
91
super &.html_safe
82
92
end
83
93
84
- # @api private
85
- def __text__ ( content )
86
- case content
87
- when ActiveSupport ::SafeBuffer
88
- @_context . target << content
89
- else
90
- super
91
- end
92
- end
93
-
94
- # TODO: Re-introduce this when we can figure out how to test it
95
- # def await(task)
96
- # case task
97
- # when ActiveRecord::Relation
98
- # future = task.instance_variable_get(:@future_result)
99
- # flush if future && future.pending?
100
- # task
101
- # else
102
- # super
103
- # end
104
- # end
105
-
106
94
# Trick ViewComponent into thinking we're a ViewComponent to fix rendering output
107
95
# @api private
108
96
def set_original_view_context ( view_context )
0 commit comments