Class: TabMenu::TabBuilder

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers::CaptureHelper, ActionView::Helpers::TagHelper
Defined in:
lib/tab_menu/tab_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(controller, current_tab = nil) ⇒ TabBuilder

Returns a new instance of TabBuilder.



7
8
9
10
# File 'lib/tab_menu/tab_builder.rb', line 7

def initialize(controller, current_tab = nil)
  @controller = controller
  @current_tab = current_tab
end

Instance Attribute Details

#output_bufferObject

Returns the value of attribute output_buffer.



6
7
8
# File 'lib/tab_menu/tab_builder.rb', line 6

def output_buffer
  @output_buffer
end

Instance Method Details

#tab(name, url, li_html_options = {}, link_to_options = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/tab_menu/tab_builder.rb', line 12

def tab(name, url, li_html_options = {}, link_to_options = {})
  #append current to the contentli class attribute if its the current page
  if (!@current_tab.nil? && @current_tab.downcase == name.downcase) || (@current_tab.nil? && @controller.current_page?(url))
    li_html_options[:class] = [li_html_options[:class], configuration.active_class].join(" ").strip()
  end
  
  (:li, name, li_html_options) do
    @controller.link_to name, url, link_to_options
  end
end