Module: BootstrapAlertHelper

Defined in:
app/helpers/bootstrap_alert_helper.rb

Overview

RAILS BOOTSTRAP ENGINE

Bootstrap Alerts & Messages twitter.github.com/bootstrap/components.html#alerts

Copyright 2012-2013 Luiz Eduardo de Oliveira Fonseca, AgĂȘncia Orangeweb Licensed under The MIT License opensource.org/licenses/MIT

Instance Method Summary collapse

Instance Method Details

#alert_block(title, alert_context = :alert, &block) ⇒ Object

Alert Blocks



41
42
43
44
45
46
47
# File 'app/helpers/bootstrap_alert_helper.rb', line 41

def alert_block title, alert_context = :alert, &block
raw '<div class="alert alert-block alert-' + alert_context.to_s + '" >' +
    	'   <a class="close" data-dismiss="alert" href="#">&times;</a>' +
    	'   <h4 class="alert-heading">' + title + '</h4>' +
        	capture(&block) +
        '</div>'
end

#alert_inline(title, alert_context = :alert, &block) ⇒ Object

Alert Blocks



54
55
56
57
58
59
60
# File 'app/helpers/bootstrap_alert_helper.rb', line 54

def alert_inline title, alert_context = :alert, &block  
raw '<div class="alert alert-' + alert_context.to_s + '" >' +
    	'   <a class="close" data-dismiss="alert" href="#">&times;</a>' +
    	'   <strong class="alert-heading">' + title + '</strong>' +
        	capture(&block) +
        '</div>'
end

#flash_messagesObject

Show Flash Messages with Bootstrap Alerts



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/helpers/bootstrap_alert_helper.rb', line 20

def flash_messages
	messages = []
	
	flash.each do |type, message|
		next if type == :timeout
		next if type == :timedout
		type = :success if type == :notice
		type = :error   if type == :alert
		text = (:div, 
		(:button, raw("&times;"), :class => "close", "data-dismiss" => "alert") +
			message, :class => "alert fade in alert-#{type}")
			messages << text if message
	end
	messages.join("\n").html_safe
end