Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for view_component #112

Open
zealot128 opened this issue Apr 27, 2021 · 2 comments
Open

Support for view_component #112

zealot128 opened this issue Apr 27, 2021 · 2 comments

Comments

@zealot128
Copy link

zealot128 commented Apr 27, 2021

view component is a library used by Github which grows in popularity for replacing partials.
I made a Proof of concept by patching into ViewComponent render method:

# config/initializers/xray_view_component.rb

if defined? Xray
  module XRayPatch
    def render_in(*args)
      result = super
      path = self.class.source_location         
      Xray.augment_template(result, path)
    end    
  end

  ViewComponent::Base.prepend(XRayPatch)                                                                                                                                                                            end

It then uses the Ruby object's name as template address. One could optimize the path extraction, but maybe someone else want's to pick up the POC and work this into this library.

Bildschirmfoto 2021-04-27 um 10 14 16

@sebfie
Copy link

sebfie commented Jul 5, 2024

To interpolate html comments I had to do :

if defined? Xray
  module XRayPatch
    def render_in(*args)
      result = super
      path = self.class.source_location
      Xray.augment_template(ActiveSupport::SafeBuffer.new(result), path)
    end
  end

  ViewComponent::Base.prepend(XRayPatch)
end

@trista-patch
Copy link

It would be amazing if this were added!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants