dansch / happy_menu

tab selection solution for rails app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

HappyMenu

Simple highlighted HTML-Menus in Rails. No more crazy view logic, no instance variables in controllers - you can be happy with your menu again.

Example

Simple Example

<% happy_menu do %>
  <% happy_menu_item "Start", dashboard_path, [{:dashboard => [:index]}] %>
  <% happy_menu_item "Projects", projects_path, [:projects] %>
  <% happy_menu_item "Log Out", logout_path, nil %>
<% end %>

Let’s say you are calling the dashboard controller’s index action.

<ul>
  <li><a href="your_dashboard_link" class="selected"></a></li>
  <li><a href="your_projects_link"></a></li>
  <li><a href="your_log_out_link"></a></li>
</ul>

Advanced Example

Still to come

Usage

HappyMenu provides simple ViewHelpers and performs the selection of a menu item based on the current controller action. It uses the controller_name and action_name to determine the current selection. It expects an array or nil. Each array element can either be a symbol or a hash. Use a symbol if all controller actions should be selected, a hash to set the selection per action.

Configuration

HappyMenu can either be customized on a global level or via each method call. See HappyMenu::Base for details.

TODO

  • Rails version testing (Not tested in Rails 3 yet)

  • Fix indentation for haml templates

Project Info

Thanks to Henning Peters for the initial idea.

Copyright © 2010 Daniel Schoppmann, released under the MIT license

About

tab selection solution for rails app


Languages

Language:Ruby 100.0%