Created
August 4, 2009 08:52
-
-
Save charly/161115 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module TabsHelper | |
# takes the block | |
def tabs_for(current_tab, &block) | |
yield Tab.new(current_tab, self) | |
end | |
class Tab | |
def initialize(current_tab, template) | |
@current_tab = current_tab | |
@template = template | |
end | |
def link_to(*args) | |
"<li #{active_class(*args)}>#{@template.link_to(*args)}</li>" | |
end | |
private | |
def active_class(*args) | |
if @current_tab.all? { |k, v| args[1][k] == v } | |
"class = 'active'" | |
end | |
end | |
end #class Tab | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment