class Olelo::MenuItem

Attributes

options[R]
parent[RW]

Public Class Methods

new(name, options = {}) click to toggle source
Calls superclass method Olelo::Menu::new
# File lib/olelo/menu.rb, line 82
def initialize(name, options = {})
  super(name)
  @parent = nil
  @options = options
end

Public Instance Methods

build_menu() click to toggle source
# File lib/olelo/menu.rb, line 92
def build_menu
  attrs = options.dup
  label = attrs.delete(:label) || Locale.translate("menu_#{path.join('_')}", fallback: titlecase(name))
  klass = [*attrs.delete(:class)].flatten.compact
  klass = klass.empty? ? '' : %{class="#{klass.join(' ')}" }
  attrs = attrs.map {|k,v| %{#{k}="#{escape_html v}"} }.join(' ')
  %{<li #{klass}id="item-#{html_id}"><a #{attrs}>#{escape_html label}</a>#{super}</li>}
end
path() click to toggle source
Calls superclass method Olelo::Menu#path
# File lib/olelo/menu.rb, line 88
def path
  parent ? parent.path << super : super
end