Class: Trestle::Toolbar::Menu::Builder
- Inherits:
-
Object
- Object
- Trestle::Toolbar::Menu::Builder
- Defined in:
- lib/trestle/toolbar/menu.rb
Instance Method Summary collapse
- #divider ⇒ Object
- #header(text) ⇒ Object
-
#initialize(menu, template) ⇒ Builder
constructor
A new instance of Builder.
- #item(options = {}, &block) ⇒ Object
- #link(content, instance_or_url = nil, options = {}, &block) ⇒ Object
Constructor Details
#initialize(menu, template) ⇒ Builder
Returns a new instance of Builder.
33 34 35 |
# File 'lib/trestle/toolbar/menu.rb', line 33 def initialize(, template) @menu, @template = , template end |
Instance Method Details
#divider ⇒ Object
52 53 54 |
# File 'lib/trestle/toolbar/menu.rb', line 52 def divider item { tag.hr(class: "dropdown-divider") } end |
#header(text) ⇒ Object
48 49 50 |
# File 'lib/trestle/toolbar/menu.rb', line 48 def header(text) item { tag.h6(text, class: "dropdown-header") } end |
#item(options = {}, &block) ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/trestle/toolbar/menu.rb', line 56 def item(={}, &block) item = block_given? ? tag.li(**, &block) : tag.li("", **) @menu.items << item nil end |
#link(content, instance_or_url = nil, options = {}, &block) ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/trestle/toolbar/menu.rb', line 37 def link(content, instance_or_url=nil, ={}, &block) if instance_or_url.is_a?(Hash) instance_or_url, = nil, instance_or_url end [:class] = Array([:class]) [:class] << "dropdown-item" item { admin_link_to(content, instance_or_url, **, &block) } end |