Module: Bootstrap::NavHelper
- Defined in:
- app/helpers/bootstrap/nav_helper.rb
Overview
Rails view helpers for various Bootstrap navigation components.
Instance Method Summary collapse
-
#brand(text, options = {}) ⇒ String
Returns a Bootstrap brand element.
-
#nav_bar { ... } ⇒ String
Returns a Bootstrap navigation bar.
-
#nav_bar_divider ⇒ String
Returns divider (vertical bar) for separating items in a nav_bar.
-
#nav_bar_link(text, url, options = {}) ⇒ String
Returns a nav_bar_link.
-
#nav_bar_links(options = {}) { ... } ⇒ String
Returns <ul> for a group of nav bar links.
-
#nav_list(options = {}) { ... } ⇒ String
Returns nav list.
-
#nav_list_header(text) ⇒ String
Returns header for nav_list.
Instance Method Details
#brand(text, options = {}) ⇒ String
Returns a Bootstrap brand element
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'app/helpers/bootstrap/nav_helper.rb', line 52 def brand(text, = {}) = () = ensure_class(, 'brand') with_environment = .delete(:with_environment) if with_environment && Rails.env != 'production' text = "#{text} - #{Rails.env}" = ensure_class(, "rails-#{Rails.env}") end url = .delete(:url) if url.present? link_to(text, url, ) else content_tag(:span, text, ) end end |
#nav_bar { ... } ⇒ String
Returns a Bootstrap navigation bar
36 37 38 39 40 41 42 |
# File 'app/helpers/bootstrap/nav_helper.rb', line 36 def () content_tag(:header, class: 'navbar') do content_tag(:nav, class: 'navbar-inner') do yield end end end |
#nav_bar_divider ⇒ String
Returns divider (vertical bar) for separating items in a nav_bar
109 110 111 |
# File 'app/helpers/bootstrap/nav_helper.rb', line 109 def content_tag(:li, nil, class: "divider-vertical") end |
#nav_bar_link(text, url, options = {}) ⇒ String
Returns a nav_bar_link
Usually called within yield block of #nav_bar
95 96 97 98 99 100 101 102 103 104 |
# File 'app/helpers/bootstrap/nav_helper.rb', line 95 def (text, url, ={}) = () active = .delete(:active) = {class: ('active' if active)} content_tag(:li, ) do link_to(text, url, ) end end |
#nav_bar_links(options = {}) { ... } ⇒ String
Returns <ul> for a group of nav bar links.
Usually called in yield block of #nav_bar
77 78 79 80 81 82 83 84 |
# File 'app/helpers/bootstrap/nav_helper.rb', line 77 def (={}) = () = ensure_class(, 'nav') content_tag(:div, ) do yield end end |
#nav_list(options = {}) { ... } ⇒ String
Returns nav list
118 119 120 121 122 123 124 125 126 |
# File 'app/helpers/bootstrap/nav_helper.rb', line 118 def nav_list(={}) = () = ensure_class(, 'well') content_tag(:div, ) do content_tag(:ul, class: 'nav nav-list') do yield end end end |
#nav_list_header(text) ⇒ String
Returns header for nav_list
132 133 134 |
# File 'app/helpers/bootstrap/nav_helper.rb', line 132 def nav_list_header(text) content_tag(:li, text, class: 'nav-header') end |