Skip to content

Commit

Permalink
Use the existing Buffered object for view component
Browse files Browse the repository at this point in the history
  • Loading branch information
joeldrapper committed May 15, 2024
1 parent 642d121 commit db0fd20
Showing 1 changed file with 1 addition and 18 deletions.
19 changes: 1 addition & 18 deletions lib/phlex/rails/sgml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,6 @@

module Phlex
module Rails
class ViewComponentDecorator
def initialize(view_component, context:)
@view_component = view_component
@context = context
end

def method_missing(*args, **kwargs, &block)
if block
@view_component.public_send(*args, **kwargs) do |*a|
@context.capture(*a, &block)
end
else
@view_component.public_send(*args, **kwargs)
end
end
end

module SGML
module ClassMethods
def render_in(...)
Expand Down Expand Up @@ -49,7 +32,7 @@ def render(*args, **kwargs, &block)
if block
@_context.target << @_view_context.render(*args, **kwargs) do |*yielded_args|
if yielded_args.length == 1 && defined?(ViewComponent::Base) && ViewComponent::Base === yielded_args[0]
capture(Phlex::Rails::ViewComponentDecorator.new(yielded_args[0], context: self), &block)
capture(Phlex::Rails::Buffered.new(yielded_args[0], view: self), &block)
else
capture(*yielded_args, &block)
end
Expand Down

0 comments on commit db0fd20

Please sign in to comment.