Class: TwitterBootstrap::TabsGenerator
- Inherits:
-
Object
- Object
- TwitterBootstrap::TabsGenerator
- Defined in:
- lib/twitter_bootstrap_helpers/tabs_generator.rb
Instance Attribute Summary collapse
-
#active_pane ⇒ Object
unloadable include ::ActionView::Helpers::UrlHelper include ::ActionView::Helpers::TagHelper.
-
#context ⇒ Object
unloadable include ::ActionView::Helpers::UrlHelper include ::ActionView::Helpers::TagHelper.
-
#options ⇒ Object
unloadable include ::ActionView::Helpers::UrlHelper include ::ActionView::Helpers::TagHelper.
-
#panes ⇒ Object
unloadable include ::ActionView::Helpers::UrlHelper include ::ActionView::Helpers::TagHelper.
Instance Method Summary collapse
- #generate(block) ⇒ Object
-
#initialize(_context, opts = {}) ⇒ TabsGenerator
constructor
A new instance of TabsGenerator.
- #pane(id, title = nil, content_or_options = nil, options = {}, &content_block) ⇒ Object
Constructor Details
#initialize(_context, opts = {}) ⇒ TabsGenerator
Returns a new instance of TabsGenerator.
8 9 10 11 12 |
# File 'lib/twitter_bootstrap_helpers/tabs_generator.rb', line 8 def initialize _context, opts={} self.context = _context self.panes = {} self. = opts end |
Instance Attribute Details
#active_pane ⇒ Object
unloadable include ::ActionView::Helpers::UrlHelper include ::ActionView::Helpers::TagHelper
6 7 8 |
# File 'lib/twitter_bootstrap_helpers/tabs_generator.rb', line 6 def active_pane @active_pane end |
#context ⇒ Object
unloadable include ::ActionView::Helpers::UrlHelper include ::ActionView::Helpers::TagHelper
6 7 8 |
# File 'lib/twitter_bootstrap_helpers/tabs_generator.rb', line 6 def context @context end |
#options ⇒ Object
unloadable include ::ActionView::Helpers::UrlHelper include ::ActionView::Helpers::TagHelper
6 7 8 |
# File 'lib/twitter_bootstrap_helpers/tabs_generator.rb', line 6 def @options end |
#panes ⇒ Object
unloadable include ::ActionView::Helpers::UrlHelper include ::ActionView::Helpers::TagHelper
6 7 8 |
# File 'lib/twitter_bootstrap_helpers/tabs_generator.rb', line 6 def panes @panes end |
Instance Method Details
#generate(block) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/twitter_bootstrap_helpers/tabs_generator.rb', line 22 def generate block buffer = context.content_tag :ul, :class=>'nav nav-tabs' do block.call(self) end buffer << generate_tab_content buffer #buffer = '' #if options[:position] == :belowe #raise 'not ready' #buffer << context.content_tag( :div, #(generate_tab_content + generate_tab_navs).html_safe, #:class => 'tabbable tabs-below') #else #context.content_tag :ul, :class=>'nav nav-tabs' do #buffer << block.call(self) #end #buffer << generate_tab_content #end #buffer.html_safe end |
#pane(id, title = nil, content_or_options = nil, options = {}, &content_block) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/twitter_bootstrap_helpers/tabs_generator.rb', line 45 def pane id, title=nil, =nil, ={}, &content_block pane = {} if block_given? pane[:content] = content_block = || {} else pane[:content] = end pane[:link] = [:link] if .has_key?(:link) pane[:tooltip] = [:tooltip] pane[:class] = ['tab-pane', [:pane_class]].compact pane[:title] = title ||= id pane[:data] = [:data] if active_pane == id or [:active] self.active_pane = id pane[:class] << :active pane[:nav_class] ||= [] pane[:nav_class] << :active end self.panes[id] = pane generate_nav_tab id, pane end |