Module: PartialsFx::Component::Slots::ClassMethods
- Included in:
- PartialsFx::Component
- Defined in:
- lib/partials_fx/component/slots.rb
Instance Method Summary collapse
Instance Method Details
#slot(slot_name, default: nil) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/partials_fx/component/slots.rb', line 5 def slot(slot_name, default: nil) define_method(slot_name) do |&block| @slots ||= {} if block @slots[slot_name] = view_context.capture(&block) nil # Prevent output during capture else @slots[slot_name] || (default.is_a?(Symbol) ? send(default) : default) end end end |