module ApplicationHelper
Public Instance Methods
flash_class(level)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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 = {})
click to toggle source
# File lib/pineapples/templates/app/helpers/application_helper.rb, line 21 def svg_tag(filename, options = {}) options[:width], options[:height] = extract_dimensions(options.delete(:size)) if options[: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"] = options[:class] if options[:class] svg["id"] = options[:id] if options[:id] svg["width"] = options[:width] if options[:width] svg["height"] = options[:height] if options[:height] raw doc end