Skip to content

christian/Simple-Tabs-Menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SimpleTabsMenu

A light-weight plugin which provides a DSL for creating tabbed navigation. Highlighting is made using regular expressions based on the current request. See the example bellow for more info.

Example

  1. In the view

    <%=
      simple_menu(:ul_class => "tabs", :li_selected_class => "selected") do |m|
        m.menu_item :url => "/", :name => "Home", :highlights_on => ["/boats"]
        m.menu_item :url => "/stats", :name => "Statistics", :highlights_on => ["/users/new", "/login"]
        m.menu_item :url => "/races", :name => "My Races", :highlights_on => ["/users/new", "/login"]
      end
    %>
  2. Via a helper

    module ApplicationHelper
      def site_menu
        simple_menu(:ul_class => "tabs", :li_selected_class => "selected") do |m|
          m.menu_item :url => "/", :name => "Home", :highlights_on => ["/boats"]
          m.menu_item :url => "/stats", :name => "Statistics", :highlights_on => ["/users/new", "/login"]
          m.menu_item :url => "/races", :name => "My Races", :highlights_on => ["/users/new", "/login"]
        end
      end
    end
    

Then inside the view:

<%= site_menu %>

This produces a menu like:

<ul class='tabs'>
    <li><a href='/' class='selected'>Home</a></li>
    <li><a href='/stats' >Statistics</a></li>
    <li><a href='/races' >My Races</a></li>
</ul>

Based on the options for each menu item, the menu figures out which tab should it mark as selected.

Authors

  • maintained by Cristi Prodan (cristiprodan.com)

  • Thanks to Alliants (alliants.co.uk) for sponsoring development and supporting open sourcing it from the start

Copyright © 2010 christian, released under the MIT license

About

Provides a small DSL for creating tabbed navigation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages