Coder Social home page Coder Social logo

happy_menu's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.