Giter Club home page Giter Club logo

semantic-menu's Introduction

= 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

semantic-menu's People

Stargazers

 avatar

Watchers

 avatar  avatar

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.