Project

rails_nav

0.01
No commit activity in last 3 years
No release in over 3 years
declarative navigation for rails applications
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project 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
        }
      }

    %>