Module: RailsBootstrapHelper::Helper
- Defined in:
- lib/rails_bootstrap_helper/helper.rb
Instance Method Summary collapse
- #badge_link_to(name, url, options = {}) ⇒ Object
- #badge_tag(status, options = {}) ⇒ Object
- #button_link_to(text, url, options = {}) ⇒ Object
- #icon_button_link_to(text, url, options) ⇒ Object
- #icon_link_to(text, url, options) ⇒ Object
- #icon_tag(icon, options = {}) ⇒ Object
- #info_tag(text) ⇒ Object
- #inline_svg(path) ⇒ Object
- #nav_link(name, path) ⇒ Object
- #pill_badge_tag(status, options = {}) ⇒ Object
- #status_tag(status, options = {}) ⇒ Object
Instance Method Details
#badge_link_to(name, url, options = {}) ⇒ Object
44 45 46 47 |
# File 'lib/rails_bootstrap_helper/helper.rb', line 44 def badge_link_to(name, url, = {}) badge = content_tag(:span, .delete(:count).presence || "", class: "badge") link_to((name + " " + badge).html_safe, url, ) end |
#badge_tag(status, options = {}) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rails_bootstrap_helper/helper.rb', line 20 def badge_tag(status, = {}) klass = ["badge"] if .has_key?(:level) klass << "badge-#{.delete(:level).to_s}" else klass << "badge-secondary" end klass << [:class].strip.split(/\s+/) unless [:class].blank? [:class] = klass.flatten.join(" ") content_tag(:span, status, ) end |
#button_link_to(text, url, options = {}) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/rails_bootstrap_helper/helper.rb', line 63 def (text, url, = {}) klass = ["btn"] if .has_key?(:level) klass << "btn-#{[:level]}" .delete(:level) else klass << "btn-secondary" end if .has_key?(:size) klass << "btn-#{[:size]}" .delete(:size) end klass << [:class].strip.split(/\s+/) unless [:class].blank? [:class] = klass.flatten.join(" ") link_to text, url, end |
#icon_button_link_to(text, url, options) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/rails_bootstrap_helper/helper.rb', line 81 def (text, url, ) klass = [""] icon = .delete(:icon) if .has_key?(:icon) icon_tag = '' if icon klazz = ["icon icon-#{icon}"] if .has_key?(:white) klazz << ["icon-white"] .delete(:white) end icon_tag = content_tag(:span, '', class: klazz.join(' ')) end klass << [:class].strip.split(/\s+/) unless [:class].blank? [:class] = klass.flatten.join(" ") (icon_tag + " #{text}").html_safe, url, end |
#icon_link_to(text, url, options) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/rails_bootstrap_helper/helper.rb', line 49 def icon_link_to(text, url, ) icon = .delete(:icon) if .has_key?(:icon) icon_tag = '' if icon icon_klass = ["icon icon-#{icon}"] if .has_key?(:white) icon_klass << ["icon-white"] .delete(:white) end icon_tag = content_tag(:span, '', class: icon_klass.join(' ')) end link_to (icon_tag + " #{text}").html_safe, url, end |
#icon_tag(icon, options = {}) ⇒ Object
99 100 101 102 103 104 |
# File 'lib/rails_bootstrap_helper/helper.rb', line 99 def icon_tag(icon, = {}) klass = ["icon icon-#{icon}"] klass << [:class].strip.split(/\s+/) unless [:class].blank? [:class] = klass.flatten.join(" ") content_tag(:span, '', class: [:class], style: [:style]) end |
#info_tag(text) ⇒ Object
4 5 6 |
# File 'lib/rails_bootstrap_helper/helper.rb', line 4 def info_tag(text) content_tag(:i, '', class: 'icon-info-sign', rel: 'tooltip', title: text) + " " end |
#inline_svg(path) ⇒ Object
106 107 108 109 |
# File 'lib/rails_bootstrap_helper/helper.rb', line 106 def inline_svg(path) file = File.open("app/assets/images/#{path}", "rb") raw file.read end |
#nav_link(name, path) ⇒ Object
111 112 113 |
# File 'lib/rails_bootstrap_helper/helper.rb', line 111 def nav_link(name, path) content_tag :li, link_to(name, path, class: 'nav-link'), class: 'nav-item' end |
#pill_badge_tag(status, options = {}) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rails_bootstrap_helper/helper.rb', line 32 def pill_badge_tag(status, = {}) klass = ["badge badge-pill"] if .has_key?(:level) klass << "badge-#{.delete(:level).to_s}" else klass << "badge-secondary" end klass << [:class].strip.split(/\s+/) unless [:class].blank? [:class] = klass.flatten.join(" ") content_tag(:span, status, ) end |
#status_tag(status, options = {}) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/rails_bootstrap_helper/helper.rb', line 8 def status_tag(status, = {}) klass = ["badge"] if .has_key?(:level) klass << "badge-#{.delete(:level).to_s}" else klass << "badge-secondary" end klass << [:class].strip.split(/\s+/) unless [:class].blank? [:class] = klass.flatten.join(" ") content_tag(:span, status, ) end |