Module: Codefabrik::Styleguide::ViewHelpers
- Defined in:
- lib/codefabrik/styleguide/view_helpers.rb
Instance Method Summary collapse
- #active_link_to(label, path, options = {}) ⇒ Object
- #breadcrumbs(links, current) ⇒ Object
- #table(headers, data) ⇒ Object
Instance Method Details
#active_link_to(label, path, options = {}) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/codefabrik/styleguide/view_helpers.rb', line 31 def active_link_to(label, path, = {}) if request.path == path existing_klass = [:klass] || '' new_klass = "#{existing_klass} active" link_to(label, path, .merge({ class: new_klass })) else link_to(label, path, ) end end |
#breadcrumbs(links, current) ⇒ Object
4 5 6 7 8 9 10 11 12 |
# File 'lib/codefabrik/styleguide/view_helpers.rb', line 4 def (links, current) output = "<div class='breadcrumbs mb-1'>" links.each do |link| output << "#{link}<span class='separator'>▶</span>" end output << current output << "</div>" output.html_safe end |
#table(headers, data) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/codefabrik/styleguide/view_helpers.rb', line 14 def table(headers, data) output = "<div class='table'><div class='thead'><div class='tr'>" headers.each do |header| output << "<div class='th'>#{header}</div>" end output << "</div></div><div class='tbody'>" data.each do |row| output << "<div class='tr'>" row.each do |cell| output << "<div class='td'>#{cell}</div>" end output << "</div>" end output << "</div></div>" output.html_safe end |