Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A plugin to make rails menus easier to write
Ruby
Branch: master
Pull request Compare This branch is 7 commits ahead, 6 commits behind danielharan:master.

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
public/stylesheets
tasks
test
MIT-LICENSE
README
Rakefile
TODO
init.rb
install.rb
semantic_navigation.gemspec
uninstall.rb

README

= SemanticMenu

A plugin to make large menus easier to write.

Supports arbitrarily deep nesting; parents will be marked as 'active' if any of its children are active.

== Example

<%= semantic_menu do |root|
  root.add "overview", root_path
  root.add "comments", comments_path
end %>

Assuming you are on /comments, the output would be:

<ul class="menu">
  <li>
    <a href="/">overview</a>
  </li>
  <li class="active">
    <a href="/comments">comments</a>
  </li>
</ul>

add and semantic_menu both take an optional parameter hash, and you can nest the menu as deeply as you want:

<%= semantic_menu :class => 'top_level_nav' do |root|
  root.add "overview", "root_path"
  root.add "comments", "comments_path", :class => 'button' do |comments|
    comments.add "My Comments", "my_comments_path"
    comments.add "Recent",      "recent_comments_path"
  end
end %>

This would look like this:

<ul class="top_level_nav">
  <li>
    <a href="root_path">overview</a>
  </li>
  <li class="active">
    <a href="comments_path" class="button">comments</a>
    <ul class="menu_level_1">
      <li class="active">
        <a href="my_comments_path">My Comments</a>
      </li>
      <li>
        <a href="recent_comments_path">Recent</a>
      </li>
    </ul>
  </li>
</ul>

Copyright (c) 2008 Daniel Haran, released under the MIT license
Something went wrong with that request. Please try again.