Class: TabsOnRails::Tabs::TabsBuilder
- Defined in:
- lib/tabs_on_rails/tabs.rb
Overview
Tabs Builder
The TabsBuilder is and example of custom Builder. It creates a new tab
Instance Method Summary collapse
-
#close_tabs ⇒ Object
Implements Builder#close_tabs.
-
#open_tabs ⇒ Object
Implements Builder#open_tabs.
-
#tab_for(tab, name, options) ⇒ Object
Implements Builder#tab_for.
Methods inherited from Builder
Constructor Details
This class inherits a constructor from TabsOnRails::Tabs::Builder
Instance Method Details
#close_tabs ⇒ Object
Implements Builder#close_tabs.
108 109 110 |
# File 'lib/tabs_on_rails/tabs.rb', line 108 def close_tabs '</ul>' end |
#open_tabs ⇒ Object
Implements Builder#open_tabs.
103 104 105 |
# File 'lib/tabs_on_rails/tabs.rb', line 103 def open_tabs '<ul>' end |
#tab_for(tab, name, options) ⇒ Object
Implements Builder#tab_for. Returns a link_to tab with name and options if tab is not the current tab, a simple tab name wrapped by a span tag otherwise.
current_tab? :foo # => true
tab_for :foo, 'Foo', foo_path
# => <li><span>Foo</span></li>
tab_for :bar, 'Bar',
# => <li><a href="/link/to/bar">Bar</a></li>
95 96 97 98 99 100 |
# File 'lib/tabs_on_rails/tabs.rb', line 95 def tab_for(tab, name, ) content = @context.link_to_unless(current_tab?(tab), name, ) do @context.content_tag(:span, name) end @context.content_tag(:li, content) end |