Module: ApplicationHelper
- Defined in:
- lib/pineapples/templates/app/helpers/application_helper.rb
Instance Method Summary collapse
- #close_button_tag(options = {}) ⇒ Object
- #flash_class(level) ⇒ Object
- #icon_tag(name) ⇒ Object
- #modal_for(id, modal_title = nil, &block) ⇒ Object
- #parent_layout(layout) ⇒ Object
- #svg_tag(filename, options = {}) ⇒ Object
Instance Method Details
#close_button_tag(options = {}) ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/pineapples/templates/app/helpers/application_helper.rb', line 38 def ( = {}) = Hash().reverse_merge!({type: 'button', class: 'close', aria: {label: 'Close'}}) content_tag :button, do content_tag :span, aria: {hidden: 'true'} do '×'.html_safe end end end |
#flash_class(level) ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/pineapples/templates/app/helpers/application_helper.rb', line 51 def flash_class(level) case level.to_sym when :notice then 'alert alert-success' when :error then 'alert alert-danger' when :alert then 'alert alert-danger' end end |
#icon_tag(name) ⇒ Object
47 48 49 |
# File 'lib/pineapples/templates/app/helpers/application_helper.rb', line 47 def icon_tag(name) content_tag :i, nil, class: "icon icon-#{name}" end |
#modal_for(id, modal_title = nil, &block) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/pineapples/templates/app/helpers/application_helper.rb', line 13 def modal_for(id, modal_title = nil, &block) modal_id = id + '-modal' modal_body = capture(&block) render partial: 'common/modal', locals: {modal_id: modal_id, modal_title: modal_title, modal_body: modal_body} end |
#parent_layout(layout) ⇒ Object
2 3 4 5 6 7 8 9 10 11 |
# File 'lib/pineapples/templates/app/helpers/application_helper.rb', line 2 def parent_layout(layout) layout = layout.to_s layout = "layouts/#{layout}" unless layout.include?('/') @view_flow.set(:layout, output_buffer) output = render file: layout self.output_buffer = ActionView::OutputBuffer.new(output) end |
#svg_tag(filename, options = {}) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/pineapples/templates/app/helpers/application_helper.rb', line 21 def svg_tag(filename, = {}) [:width], [:height] = extract_dimensions(.delete(:size)) if [:size] assets = Rails.application.assets file = assets.find_asset(filename + '.svg').body.force_encoding('UTF-8') doc = Nokogiri::HTML::DocumentFragment.parse file svg = doc.at_css 'svg' svg["class"] = [:class] if [:class] svg["id"] = [:id] if [:id] svg["width"] = [:width] if [:width] svg["height"] = [:height] if [:height] raw doc end |