objectified navigation for rails
Ruby
Switch branches/tags
Nothing to show
Latest commit 87b99aa Sep 7, 2016 @ahoward string*ex*. v2.8.0
Permalink
Failed to load latest commit information.
lib string*ex*. v2.8.0 Sep 7, 2016
pkg string*ex*. v2.8.0 Sep 7, 2016
.gitignore gem desc Feb 15, 2014
README v1.0.0. no html shit. just logic. Mar 13, 2012
Rakefile version Feb 22, 2014
rails_nav.gemspec string*ex*. v2.8.0 Sep 7, 2016

README

NAME
  rails_nav.rb

SYNOPSIS
  encapsulates only the concept of a

    "named list of linkys"

  and

    "how to make one 'em active"

  it does *not* to any htmly stuff for you


USAGE

  in a controller

    class ApplicationController < ActionController::Base

      nav_for :main do |list|
        if current_user
          list.link(:home, root_path)
          list.link(:test, test_path)
        end

        if current_user.admin?
          list.link(:admin, admin_path)
        end
      end

    end

    # pass a block to list.link(...){ } to supply logic for when a link is
    # active.  otherwise a sane default will be built for you.

  in a view

    <%=

      nav_{
        ul_(:class => 'nav nav-pills'){
          nav_for(:main).each do |link|

            li_(:class => (link.active ? :active : :inactive)){
              a_(:href => link.href){ link }
            }

          end
        }
      }

    %>