Sha256: d3857a371c45d884f2525dd52fb050e026700d2ffd7c2169d9e072be941ea5c1
Contents?: true
Size: 1.29 KB
Versions: 2
Compression:
Stored size: 1.29 KB
Contents
require 'helpers' module FlashBlockHelper def flash_block(options={}) content = [] flash.each do |type, message| content << bs_alert(type, message) end content_tag :div, content.join("\n").html_safe, options end def bs_alert(type, message, options={}) alert_options = options.dup alert_options[:class] = parse_html_classes_to_arr alert_options[:class] alert_options[:class] << 'alert' alert_options[:class] << 'alert-dismissable' alert_options[:class] << alert_class(type) content = [] content << content_tag(:button, '×'.html_safe, class: 'close', type: 'button', data: {dismiss: :alert}, aria: {hidden: 'true'}) content << message content_tag :div, content.join("\n").html_safe, alert_options end private #Render rules #- `:success` render as `.alert-success`; #- `:info` render as `.alert-info`; #- `:warning` render as `.alert-warning`; #- `:danger` render as `.alert-danger`; #- `:notice` render as `.alert-success`; #- `:alert` render as `.alert-danger`; #- another keys render as `alert-info`. def alert_class(type) act_type = case type when :success, :notice then :success when :danger, :alert then :danger when :warning, :info then type else :info end "alert-#{act_type}" end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
twitter-bootstrap-for-rails-1.3.4 | app/helpers/flash_block_helper.rb |
twitter-bootstrap-for-rails-1.3.3 | app/helpers/flash_block_helper.rb |