Class: Tabnav::Navbar
Instance Attribute Summary collapse
-
#tab_content_partial ⇒ Object
writeonly
Optionally specifies a partial to be used to render the tab content.
Attributes inherited from Tab
#link_options, #link_url, #name
Instance Method Summary collapse
-
#add_sub_nav(options = {}, &block) ⇒ Object
Creates a sub Navbar and adds it to the navbar.
-
#add_tab(options = {}, &block) ⇒ Object
Creates a Tab and adds it to the navbar.
-
#initialize(template, params, html_options = {}) ⇒ Navbar
constructor
:nodoc:.
-
#render_navbar ⇒ Object
:nodoc:.
Methods inherited from Tab
#active?, #has_link?, #highlights_on, #links_to, #named, #render
Constructor Details
#initialize(template, params, html_options = {}) ⇒ Navbar
:nodoc:
3 4 5 6 7 8 |
# File 'lib/tabnav/navbar.rb', line 3 def initialize(template, params, = {}) # :nodoc: @top_level = .delete(:top_level) super @tabs = [] @tab_content_partial = @partial end |
Instance Attribute Details
#tab_content_partial=(value) ⇒ Object (writeonly)
Optionally specifies a partial to be used to render the tab content.
11 12 13 |
# File 'lib/tabnav/navbar.rb', line 11 def tab_content_partial=(value) @tab_content_partial = value end |
Instance Method Details
#add_sub_nav(options = {}, &block) ⇒ Object
Creates a sub Navbar and adds it to the navbar.
options
is an optional hash of options which will be used to create the li
containing the sub navbar.
yields the created Navbar
27 28 29 |
# File 'lib/tabnav/navbar.rb', line 27 def add_sub_nav( = {}, &block) add_item(Navbar, , &block) end |
#add_tab(options = {}, &block) ⇒ Object
Creates a Tab and adds it to the navbar.
options
is an optional hash of options which will be used to create the li
for the tab.
yields the created Tab
18 19 20 |
# File 'lib/tabnav/navbar.rb', line 18 def add_tab( = {}, &block) add_item(Tab, , &block) end |
#render_navbar ⇒ Object
:nodoc:
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/tabnav/navbar.rb', line 31 def # :nodoc: return ''.html_safe if @tabs.empty? @template.content_tag :ul, @top_level ? @html_options : nil do contents = ''.html_safe @tabs.each do |tab| contents << tab.render end contents end end |