Method: Espresso::View::InstanceMethods#navigation_list

Defined in:
lib/espresso/view.rb

Draws navigation list, using <li> with <a>

Parameters:

  • menu (Array<Symbol, String>)

    list of menu items (paths without /)

Returns:

  • (String)

    Resulting menu without <ul> or <ol>



170
171
172
173
174
175
176
177
178
179
180
181
182
183
# File 'lib/espresso/view.rb', line 170

def navigation_list(menu)
  ''.tap do |result|
    menu.each do |item|
      path = "/#{item}"
      uri = request.request_uri
      title = t("navigation.#{item}.index", :default => item.to_s.camelize)
      result << (:li, :class => uri.starts_with?(path) ? 'selected' : nil) do
        link_to_unless_current(title, path) {
          (:strong, title)
        }
      end
    end
  end
end