Class: TabsFor::Rails::TabsForHelper::TabBuilder

Inherits:
ViewBuilder
  • Object
show all
Includes:
FontAwesome::Rails::IconHelper
Defined in:
app/helpers/tabs_for/rails/tabs_for_helper.rb

Instance Attribute Summary

Attributes inherited from ViewBuilder

#object, #output_buffer, #template

Instance Method Summary collapse

Methods inherited from ViewBuilder

#initialize

Constructor Details

This class inherits a constructor from TabsFor::Rails::TabsForHelper::ViewBuilder

Instance Method Details

#tab(attribute, options = {}) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'app/helpers/tabs_for/rails/tabs_for_helper.rb', line 33

def tab(attribute, options = {})
  content = if options[:label]
              options.delete(:label)
            elsif object.respond_to? attribute
              human_name attribute
            else
              attribute.to_s.titleize
            end

  id = options[:id] ? options[:id].to_s : identifier(attribute)

  if options[:size]
    content += ' ' + (:span, options[:size], class: 'badge')
  end

  (:li, apply_options(attribute, options)) do
    link_to '#' + id, apply_link_options(id) do
      if options[:icon]
        wrap_with_icon(content.html_safe, options)
      else
        content.html_safe
      end
    end
  end
end