Module: BootstrapNavbar::Helpers::Bootstrap2
- Defined in:
- lib/bootstrap-navbar/helpers/bootstrap2.rb
Instance Method Summary collapse
- #navbar(options = {}, wrapper_options = {}, &block) ⇒ Object
- #navbar_brand_link(name, url = nil) ⇒ Object
- #navbar_divider ⇒ Object
- #navbar_dropdown(name, &block) ⇒ Object
- #navbar_dropdown_divider ⇒ Object
- #navbar_dropdown_header(text) ⇒ Object
- #navbar_group(options = {}, &block) ⇒ Object
- #navbar_item(name = nil, path = nil, list_item_options = nil, link_options = nil, &block) ⇒ Object
- #navbar_sub_dropdown(name, list_item_options = {}, link_options = {}, &block) ⇒ Object
- #navbar_text(text = nil, pull = nil, &block) ⇒ Object
Instance Method Details
#navbar(options = {}, wrapper_options = {}, &block) ⇒ Object
2 3 4 5 6 7 8 |
# File 'lib/bootstrap-navbar/helpers/bootstrap2.rb', line 2 def ( = {}, = {}, &block) wrapper , do inner_wrapper do container [:brand], [:brand_link], [:responsive], [:fluid], &block end end end |
#navbar_brand_link(name, url = nil) ⇒ Object
90 91 92 |
# File 'lib/bootstrap-navbar/helpers/bootstrap2.rb', line 90 def (name, url = nil) prepare_html %(<a href="#{url || '/'}" class="brand">#{name}</a>) end |
#navbar_divider ⇒ Object
76 77 78 |
# File 'lib/bootstrap-navbar/helpers/bootstrap2.rb', line 76 def prepare_html %(<li class="divider-vertical"></li>) end |
#navbar_dropdown(name, &block) ⇒ Object
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/bootstrap-navbar/helpers/bootstrap2.rb', line 42 def (name, &block) prepare_html <<-HTML.chomp! <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown"> #{name} <b class="caret"></b> </a> #{(&block)} </li> HTML end |
#navbar_dropdown_divider ⇒ Object
68 69 70 |
# File 'lib/bootstrap-navbar/helpers/bootstrap2.rb', line 68 def prepare_html %(<li class="divider"></li>) end |
#navbar_dropdown_header(text) ⇒ Object
72 73 74 |
# File 'lib/bootstrap-navbar/helpers/bootstrap2.rb', line 72 def (text) prepare_html %(<li class="nav-header">#{text}</li>) end |
#navbar_group(options = {}, &block) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/bootstrap-navbar/helpers/bootstrap2.rb', line 10 def ( = {}, &block) = .dup [:class] = [[:class], 'nav'].compact [:class] << "pull-#{.delete(:pull)}" if .key?(:pull) [:class] = [:class].join(' ') attributes = attributes_for_tag() prepare_html <<-HTML.chomp! <ul#{attributes}> #{capture(&block) if block_given?} </ul> HTML end |
#navbar_item(name = nil, path = nil, list_item_options = nil, link_options = nil, &block) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/bootstrap-navbar/helpers/bootstrap2.rb', line 23 def (name = nil, path = nil, = nil, = nil, &block) name, path, , = capture(&block), name, path, if block_given? path ||= '#' = ? .dup : {} = ? .dup : {} [:class] = [[:class]].compact [:class] << 'active' if current_url_or_sub_url?(path) [:class] = [:class].join(' ') list_item_attributes = attributes_for_tag() link_attributes = attributes_for_tag() prepare_html <<-HTML.chomp! <li#{list_item_attributes}> <a href="#{path}"#{link_attributes}> #{name} </a> </li> HTML end |
#navbar_sub_dropdown(name, list_item_options = {}, link_options = {}, &block) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/bootstrap-navbar/helpers/bootstrap2.rb', line 53 def (name, = {}, = {}, &block) , = .dup, .dup [:class] = [.delete(:class), 'dropdown-submenu'].compact.join(' ') list_item_attributes = attributes_for_tag() link_attributes = attributes_for_tag() prepare_html <<-HTML.chomp! <li#{list_item_attributes}> <a href="#"#{link_attributes}> #{name} </a> #{(&block)} </li> HTML end |
#navbar_text(text = nil, pull = nil, &block) ⇒ Object
80 81 82 83 84 85 86 87 88 |
# File 'lib/bootstrap-navbar/helpers/bootstrap2.rb', line 80 def (text = nil, pull = nil, &block) css_classes = %w(navbar-text) css_classes << "pull-#{pull}" if pull prepare_html <<-HTML.chomp! <p class="#{css_classes.join(' ')}"> #{block_given? ? capture(&block) : text} </p> HTML end |