Module: LocoMotion::Patches::ViewComponent::SlotableDefaultPatch

Defined in:
lib/loco_motion/patches/view_component/slotable_default_patch.rb

Overview

Monkey patches ViewComponent::SlotableDefault so get_slot forces the component's content block to run first — any slots the block sets need to be registered before get_slot can correctly decide whether to fall back to a slot's default value.

Instance Method Summary collapse

Instance Method Details

#get_slot(slot_name) ⇒ Object

Force content to run first so any slots it sets get registered before deciding whether to fall back to this slot's default value.



15
16
17
18
19
20
21
# File 'lib/loco_motion/patches/view_component/slotable_default_patch.rb', line 15

def get_slot(slot_name)
  # ensure content is loaded so slots will be defined
  content unless content_evaluated?

  # Call the original implementation
  super
end