Module: Codefabrik::Styleguide::ViewHelpers

Defined in:
lib/codefabrik/styleguide/view_helpers.rb

Instance Method Summary collapse

Instance Method Details



31
32
33
34
35
36
37
38
39
# File 'lib/codefabrik/styleguide/view_helpers.rb', line 31

def active_link_to(label, path, options = {})
  if request.path == path
    existing_klass = options[:klass] || ''
    new_klass = "#{existing_klass} active"
    link_to(label, path, options.merge({ class: new_klass }))
  else
    link_to(label, path, options)
  end
end


4
5
6
7
8
9
10
11
12
# File 'lib/codefabrik/styleguide/view_helpers.rb', line 4

def breadcrumbs(links, current)
  output = "<div class='breadcrumbs mb-1'>"
  links.each do |link|
    output << "#{link}<span class='separator'>&#9654;</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