module Spark::Component::Integration
Public Class Methods
base_class()
click to toggle source
# File lib/spark/component/integration/action_view_component.rb, line 6 def self.base_class ActionView::Component::Base end
included(base)
click to toggle source
# File lib/spark/component/integration/action_view_component.rb, line 10 def self.included(base) base.extend(ClassMethods) end
Public Instance Methods
render_in(view_context, &block)
click to toggle source
Override ActionView::Components::Base `render_in` This is only necessary in order to pass `self` as a block parameter
# File lib/spark/component/integration/action_view_component.rb, line 16 def render_in(view_context, &block) self.class.compile @view_context = view_context @view_renderer ||= view_context.view_renderer @lookup_context ||= view_context.lookup_context @view_flow ||= view_context.view_flow @virtual_path ||= virtual_path @variant = @lookup_context.variants.first old_current_template = @current_template @current_template = self # Pass self as a block parameter @content = render_block(view_context, &block) if block_given? validate! send(self.class.call_method_name(@variant)) ensure @current_template = old_current_template end
render_self()
click to toggle source
# File lib/spark/component/integration/action_view_component.rb, line 36 def render_self # Guard with `rendered?` boolean in case render_block returns `nil` return @render_self if rendered? @rendered = true @render_self = render_in(@view_context, &@_block) end