Class: NavbarHelper::Navbar
- Inherits:
-
Object
- Object
- NavbarHelper::Navbar
- Defined in:
- app/helpers/navbar_helper.rb
Instance Attribute Summary collapse
-
#parent ⇒ Object
Returns the value of attribute parent.
Instance Method Summary collapse
- #button(text, options = {}) ⇒ Object
- #group(options = {}, &block) ⇒ Object
-
#initialize(parent) ⇒ Navbar
constructor
A new instance of Navbar.
- #link(text, uri, options = {}) ⇒ Object
- #text(text, options = {}) ⇒ Object
Constructor Details
#initialize(parent) ⇒ Navbar
Returns a new instance of Navbar.
69 70 71 |
# File 'app/helpers/navbar_helper.rb', line 69 def initialize(parent) self.parent = parent end |
Instance Attribute Details
#parent ⇒ Object
Returns the value of attribute parent.
67 68 69 |
# File 'app/helpers/navbar_helper.rb', line 67 def parent @parent end |
Instance Method Details
#button(text, options = {}) ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'app/helpers/navbar_helper.rb', line 92 def (text, ={}) = .dup [:class] = parse_html_classes_to_arr [:class] [:class] << 'btn' [:class] << 'navbar-btn' unless [:class].join =~ /btn-(?>default|primary|warning|success|info|danger|link)/ [:class] << 'btn-default' end content_tag :button, text, end |
#group(options = {}, &block) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'app/helpers/navbar_helper.rb', line 75 def group(={}, &block) = NavbarGroup.new self.parent content = capture , &block = .dup [:class] = parse_html_classes_to_arr [:class] [:class] << 'nav' [:class] << 'navbar-nav' pull = .delete(:pull).to_s if pull == 'left' || pull == 'right' [:class] << "navbar-#{pull}" end content_tag :ul, content, end |
#link(text, uri, options = {}) ⇒ Object
119 120 121 122 123 124 125 126 |
# File 'app/helpers/navbar_helper.rb', line 119 def link(text, uri, ={}) = .dup [:class] = parse_html_classes_to_arr [:class] [:class] << 'navbar-link' [:href] = uri content_tag :a, text, end |
#text(text, options = {}) ⇒ Object
105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'app/helpers/navbar_helper.rb', line 105 def text(text, ={}) = .dup [:class] = parse_html_classes_to_arr [:class] [:class] << 'navbar-text' pull = .delete(:pull).to_s if pull == 'left' || pull == 'right' [:class] << "navbar-#{pull}" end content_tag :p, text, end |