= sga_nav == Usage to build a navigation li : to build a sub nav:
when user view pages correspoding to actions in users controller, we'd like the tab "User" highlight, to accomplish this: class UsersController < ApplicationController main_nav_highlight :users # bla bla bla ... end also if you need to highlight the sub nav, call "sec_nav_highlight :something" in your controller == Code module Navigation module ControllerExtensions module ClassMethods def sec_nav_highlight(name) class_eval do before_filter { |c| c.instance_variable_set(:@sec_nav, name) } end end def main_nav_highlight(name) class_eval do before_filter { |c| c.instance_variable_set(:@main_nav, name) } end end end end module RailsHelpers def sec_nav(name, options = {}, &block) if @sec_nav == name if options[:class] options[:class] += " active" else options[:class] = "active" end end content = capture(&block) concat content_tag(:li, content, options) end def main_nav(name, options = {}, &block) if @main_nav == name if options[:class] options[:class] += " active" else options[:class] = "active" end end content = capture(&block) concat content_tag(:li, content, options) end end end ActionController::Base.send :extend, Navigation::ControllerExtensions::ClassMethods ActionController::Base.send :helper, Navigation::RailsHelpers == Note on Patches/Pull Requests * Fork the project. * Make your feature addition or bug fix. * Add tests for it. This is important so I don't break it in a future version unintentionally. * Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull) * Send me a pull request. Bonus points for topic branches. == Copyright Copyright (c) 2010 tim.teng. See LICENSE for details.