Module: Btgen::Helper
- Defined in:
- lib/btgen/helper.rb
Instance Method Summary collapse
- #bootstrap_description(instance, attributes) ⇒ Object
- #bootstrap_table(args = {}) {|table| ... } ⇒ Object
- #expand_collapsible_label(target_id) ⇒ Object
- #panel_with_body(*args) ⇒ Object
Instance Method Details
#bootstrap_description(instance, attributes) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/btgen/helper.rb', line 43 def bootstrap_description(instance, attributes) content_tag :dl, class: 'dl-horizontal' do attributes.to_a.map do |(k, v)| (content_tag :dt, instance.class.human_attribute_name(k)) + (content_tag :dd, v) end.inject(:+) end end |
#bootstrap_table(args = {}) {|table| ... } ⇒ Object
5 6 7 8 9 |
# File 'lib/btgen/helper.rb', line 5 def bootstrap_table(args = {}) table = BootstrapTable.new args yield table table.to_html end |
#expand_collapsible_label(target_id) ⇒ Object
11 12 13 |
# File 'lib/btgen/helper.rb', line 11 def (target_id) icon :plus, href: "##{target_id}", data: {toggle: 'collapse'} end |
#panel_with_body(*args) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/btgen/helper.rb', line 15 def panel_with_body(*args) body_classes = ['panel-body'] random_string = (0...8).map { (65 + rand(26)).chr }.join = {id: "collapsible_#{random_string.downcase}"} title_fragments = [] if args.last[:icon] title_fragments << icon(args.last[:icon][:type].to_sym, class: args.last[:icon][:class]) end if args.last[:collapsible] body_classes << 'collapse' title_fragments << ([:id]) end title_fragments << sanitize(args.last[:title]) args.last[:title] = title_fragments.compact.inject(:+).html_safe panel(*args) do [:class] = body_classes.join(' ') content_tag :div, do yield end end end |