Module: Pinmark::Hooks::ViewComponent

Defined in:
lib/pinmark/hooks/view_component.rb

Overview

Prepended into ViewComponent::Base when the gem is present. Inert until then. Mirrors the Phlex ‘Components::Base#around_template` hook by wrapping `render_in`’s output in pinmark markers.

Instance Method Summary collapse

Instance Method Details

#render_in(view_context) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/pinmark/hooks/view_component.rb', line 9

def render_in(view_context, &)
  return super unless Pinmark.active?

  component = self.class.name || "anonymous"
  source = Pinmark::SourceLocator.for(self.class) || "unknown"

  Pinmark::Wrapper.wrap(component:, source:) do
    super
  end
end