class TabsOnRails::Tabs

Attributes

default_builder[W]

Public Class Methods

default_builder() click to toggle source
# File lib/tabs_on_rails/tabs.rb, line 20
def default_builder
  @default_builder ||= TabsBuilder
end
new(context, options = {}) click to toggle source
# File lib/tabs_on_rails/tabs.rb, line 25
def initialize(context, options = {})
  @context = context
  @builder = (options.delete(:builder) || self.class.default_builder).new(@context, options)
  @options = options
end

Public Instance Methods

method_missing(*args, &block) click to toggle source
# File lib/tabs_on_rails/tabs.rb, line 42
def method_missing(*args, &block)
  @builder.tab_for(*args, &block)
end
render(&block) click to toggle source

Renders the tab stack using the current builder.

Returns the String HTML content.

# File lib/tabs_on_rails/tabs.rb, line 50
def render(&block)
  raise LocalJumpError, "no block given" unless block_given?

  options = @options.dup
  open_tabs_options  = options.delete(:open_tabs)  || {}
  close_tabs_options = options.delete(:close_tabs) || {}

  "".tap do |html|
    html << open_tabs(open_tabs_options).to_s
    html << @context.capture(self, &block)
    html << close_tabs(close_tabs_options).to_s
  end.html_safe
end