Class: Decidim::MenuItemPresenter
- Inherits:
-
Object
- Object
- Decidim::MenuItemPresenter
- Defined in:
- app/presenters/decidim/menu_item_presenter.rb
Overview
A presenter to render menu items
Direct Known Subclasses
Instance Method Summary collapse
- #active? ⇒ Boolean
-
#initialize(menu_item, view, options = {}) ⇒ MenuItemPresenter
constructor
Initializes a menu item for presentation.
- #render ⇒ Object
Constructor Details
#initialize(menu_item, view, options = {}) ⇒ MenuItemPresenter
Initializes a menu item for presentation
19 20 21 22 23 |
# File 'app/presenters/decidim/menu_item_presenter.rb', line 19 def initialize(, view, = {}) @menu_item = @view = view @options = OpenStruct.new() end |
Instance Method Details
#active? ⇒ Boolean
41 42 43 |
# File 'app/presenters/decidim/menu_item_presenter.rb', line 41 def active? is_active_link?(url, active) end |
#render ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/presenters/decidim/menu_item_presenter.rb', line 28 def render content_tag :li, role: :menuitem, class: link_wrapper_classes do output = if url == "#" [content_tag(:span, composed_label, class: "sidebar-menu__item-disabled")] else [link_to(composed_label, url, )] end output.push(@view.send(:simple_menu, **@menu_item.).render) if @menu_item. safe_join(output) end end |