Module: Bootstrap::NavHelper
- Includes:
- ActionView::Helpers::SanitizeHelper
- Defined in:
- app/helpers/bootstrap/nav_helper.rb
Overview
Rails view helpers for various Bootstrap navigation components.
See: http://twitter.github.io/bootstrap/components.html#navbar
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
Usually called in
yieldblock of #nav_bar. -
#nav_bar_text(text, options = {}) ⇒ String
Wraps text so it has proper leading and color for text in a nav bar.
-
#nav_bar_wrapper(options = {}) ⇒ Object
Returns
for a group of nav bar links,- s.
- #nav_list(options = {}) { ... } ⇒ String
Returns nav list.
- #nav_list_header(text) ⇒ String
Returns header for nav_list.
- #vertical_nav(options = {}) ⇒ Object
Instance Method Details
#brand(text, options = {}) ⇒ String
Returns a Bootstrap brand element
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
# File 'app/helpers/bootstrap/nav_helper.rb', line 53 def brand(text, = {}) = () = ensure_class(, 'navbar-brand') with_environment = .delete(:with_environment) if with_environment && Rails.env != 'production' if text.present? text = "#{text} - #{Rails.env}" else text = Rails.env end = ensure_class(, "rails-#{Rails.env}") end url = .delete(:url) content_tag(:div, class: "navbar-header") do if url.present? link_to(text, url, ) else content_tag(:span, text, ) end end end
#nav_bar { ... } ⇒ String
Returns a Bootstrap navigation bar
37 38 39 40 41 42 43
# File 'app/helpers/bootstrap/nav_helper.rb', line 37 def () content_tag(:nav, class: 'navbar navbar-default') do content_tag(:div, class: 'container-fluid') do yield end end end
#nav_bar_divider ⇒ String
Returns divider (vertical bar) for separating items in a nav_bar
127 128 129
# File 'app/helpers/bootstrap/nav_helper.rb', line 127 def content_tag(:li, nil, class: "divider") end
#nav_bar_link(text, url, options = {}) ⇒ String
Returns a nav_bar_link
Usually called within yield block of #nav_bar
113 114 115 116 117 118 119 120 121 122
# File 'app/helpers/bootstrap/nav_helper.rb', line 113 def (text, url, ={}) = () active = .delete(:active) = ensure_class({class: ('active' if active)}, "") content_tag(:li, ) do link_to(text, url, ) end end
#nav_bar_links(options = {}) { ... } ⇒ String
Usually called in
yieldblock of #nav_bar - #nav_list(options = {}) { ... } ⇒ String