Class: Decidim::MenuPresenter

Inherits:
Object
  • Object
show all
Defined in:
app/presenters/decidim/menu_presenter.rb

Overview

A presenter to render menus

Direct Known Subclasses

InlineMenuPresenter

Instance Method Summary collapse

Constructor Details

#initialize(name, view, options = {}) ⇒ MenuPresenter

Initializes a menu for presentation

Parameters:

  • name (Symbol)

    The name of the menu registry to be rendered

  • view (ActionView::Base)

    The view scope to render the menu

  • options (Hash) (defaults to: {})

    The rendering options for the menu entries



13
14
15
16
17
# File 'app/presenters/decidim/menu_presenter.rb', line 13

def initialize(name, view, options = {})
  @name = name
  @view = view
  @options = options
end

Instance Method Details

#evaluated_menuObject



22
23
24
25
26
27
28
# File 'app/presenters/decidim/menu_presenter.rb', line 22

def evaluated_menu
  @evaluated_menu ||= begin
    menu = Menu.new(@name)
    menu.build_for(@view)
    menu
  end
end

#renderObject



30
31
32
33
34
# File 'app/presenters/decidim/menu_presenter.rb', line 30

def render
   :nav, class: "main-nav", "aria-label": @options.fetch(:label, nil) do
    render_menu
  end
end