Class: PhlexUI::Accordion::Builder

Inherits:
Base
  • Object
show all
Defined in:
lib/phlex_ui/accordion/builder.rb

Instance Attribute Summary

Attributes inherited from Base

#attrs

Instance Method Summary collapse

Methods inherited from Base

#before_template, #initialize

Constructor Details

This class inherits a constructor from PhlexUI::Base

Instance Method Details

#add_item(title, content, open: false) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/phlex_ui/accordion/builder.rb', line 11

def add_item(title, content, open: false)
  render Accordion::Item.new(open: open) do
    render PhlexUI::Accordion::Trigger.new do
      render PhlexUI::Accordion::DefaultTrigger.new { title }
    end
    render PhlexUI::Accordion::Content.new do
      render PhlexUI::Accordion::DefaultContent.new { content }
    end
  end
end

#view_template(&block) ⇒ Object



5
6
7
8
9
# File 'lib/phlex_ui/accordion/builder.rb', line 5

def view_template(&block)
  render PhlexUI::Accordion.new(**attrs) do
    block.call
  end
end