Class: Tabnav::Navbar
- Inherits:
-
Object
- Object
- Tabnav::Navbar
- Defined in:
- lib/tabnav/navbar.rb
Instance Attribute Summary collapse
-
#tab_content_partial ⇒ Object
writeonly
Optionally specifies a partial to be used to render the tab content.
Instance Method Summary collapse
-
#add_tab(options = {}) {|t| ... } ⇒ Object
Creates a Tab and adds it to the navbar.
-
#initialize(template, params, options = {}) ⇒ Navbar
constructor
:nodoc:.
-
#render ⇒ Object
:nodoc:.
Constructor Details
#initialize(template, params, options = {}) ⇒ Navbar
:nodoc:
3 4 5 6 7 8 |
# File 'lib/tabnav/navbar.rb', line 3 def initialize(template, params, = {}) # :nodoc: @template = template @params = params @html_options = @tabs = [] 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_tab(options = {}) {|t| ... } ⇒ 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 21 22 23 |
# File 'lib/tabnav/navbar.rb', line 18 def add_tab( = {}) [:tab_content_partial] = @tab_content_partial if @tab_content_partial t = Tab.new(@template, @params, ) yield t @tabs << t end |
#render ⇒ Object
:nodoc:
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/tabnav/navbar.rb', line 25 def render # :nodoc: return '' if @tabs.empty? @template.content_tag :ul, @html_options do contents = ''.html_safe @tabs.each do |tab| contents << tab.render end contents end end |