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
50 51 52 53 54 55 56 57 58 59 60 |
# File 'app/helpers/bootstrap/nav_helper.rb', line 50 def brand(text, = {}) = () = ensure_class(, 'brand') 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
100 101 102 |
# File 'app/helpers/bootstrap/nav_helper.rb', line 100 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
86 87 88 89 90 91 92 93 94 95 |
# File 'app/helpers/bootstrap/nav_helper.rb', line 86 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
68 69 70 71 72 73 74 75 |
# File 'app/helpers/bootstrap/nav_helper.rb', line 68 def (={}) = () = ensure_class(, 'nav') content_tag(:div, ) do yield end end |
#nav_list(options = {}) { ... } ⇒ String
Returns nav list
109 110 111 112 113 114 115 116 117 |
# File 'app/helpers/bootstrap/nav_helper.rb', line 109 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
122 123 124 |
# File 'app/helpers/bootstrap/nav_helper.rb', line 122 def nav_list_header(text) content_tag(:li, text, class: 'nav-header') end |