Module: Ext::ViewSlot::Helpers

Defined in:
lib/ext/view_slot.rb

Instance Method Summary collapse

Instance Method Details

#render_slots(*slots) ⇒ Object

Call this before using the slots



33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/ext/view_slot.rb', line 33

def render_slots(*slots)
  slots.each do |name|
    name = name.to_s
    @__view_slots[name] = if block = @__view_slots[name]
      m = app::Mab.new({},self)
      m.capture &block
    elsif respond_to? "_#{name}"
      m = app::Mab.new({},self)
      m.capture { send "_#{name}" }
    else
      nil
    end
  end
end

#slot(name, &block) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/ext/view_slot.rb', line 22

def slot(name, &block)
  name = name.to_s
  if block_given?
    @__view_slots[name] = block
    return nil
  else 
    return @__view_slots[name]
  end
end