Module: RailsBootstrapHelpers::LayoutHelper

Defined in:
app/helpers/rails_bootstrap_helpers/layout_helper.rb

Instance Method Summary collapse

Instance Method Details

#bootstrap_button_class(color = nil) ⇒ Object



30
31
32
33
34
35
36
37
38
39
# File 'app/helpers/rails_bootstrap_helpers/layout_helper.rb', line 30

def bootstrap_button_class(color = nil)
  case color
    when :red then "btn btn-danger"
    when :blue then "btn btn-primary"
    when :light_blue then "btn btn-info"
    when :green then "btn btn-success"
    when :yellow then "btn btn-warning"
    else "btn"
  end
end

#bootstrap_label(text, type) ⇒ Object



41
42
43
# File 'app/helpers/rails_bootstrap_helpers/layout_helper.rb', line 41

def bootstrap_label(text, type)
  (:span, text, class: "label #{type.to_s}")
end


25
26
27
28
# File 'app/helpers/rails_bootstrap_helpers/layout_helper.rb', line 25

def bootstrap_link_to(title, link, color, options = {})
  btn_class = bootstrap_button_class(color).concat(options[:class] || "")
  raw(link_to title, link, { class: btn_class }.merge(options))
end

#conditional_bootstrap_label(condition, text, success = :success, failure = :important) ⇒ Object



45
46
47
# File 'app/helpers/rails_bootstrap_helpers/layout_helper.rb', line 45

def conditional_bootstrap_label(condition, text, success = :success, failure = :important)
  condition ? bootstrap_label(text, success) : bootstrap_label(text, failure)
end

#pills(&block) ⇒ Object



9
10
11
# File 'app/helpers/rails_bootstrap_helpers/layout_helper.rb', line 9

def pills(&block)
  list_builder "nav-pills", &block
end

#stacked_pills(&block) ⇒ Object



21
22
23
# File 'app/helpers/rails_bootstrap_helpers/layout_helper.rb', line 21

def stacked_pills(&block)
  list_builder "nav-pills","nav-stacked", &block
end

#stacked_tabs(&block) ⇒ Object



17
18
19
# File 'app/helpers/rails_bootstrap_helpers/layout_helper.rb', line 17

def stacked_tabs(&block)
  list_builder "nav-tabs", "nav-stacked", &block
end

#striped_table(id = nil, &block) ⇒ Object



4
5
6
7
# File 'app/helpers/rails_bootstrap_helpers/layout_helper.rb', line 4

def striped_table(id=nil, &block)
  content = capture(&block)
  (:table, content, id: id, class: "table table-bordered table-striped")
end

#tabs(&block) ⇒ Object



13
14
15
# File 'app/helpers/rails_bootstrap_helpers/layout_helper.rb', line 13

def tabs(&block)
  list_builder "nav-tabs", &block
end