Module: BootstrapPanelHelper

Defined in:
app/helpers/bootstrap_panel_helper.rb

Instance Method Summary collapse

Instance Method Details

#panel(options = {}, &block) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/helpers/bootstrap_panel_helper.rb', line 4

def panel(options={}, &block)
	unless block_given?
		raise 'Missing block'
	end

	panel_options = options.dup
	panel_options[:class] = parse_html_classes_to_arr panel_options[:class]
	panel_options[:class] << 'panel'

	header = panel_options.delete :header
	title = panel_options.delete :title
	footer = panel_options.delete :footer
	context = panel_options.delete :context

	unless %w(primary info success warning danger).include? context.to_s
		context = :default
	end

	panel_options[:class] << "panel-#{context}"

	content = []
	content << panel_header(header || title)
	content << panel_body(&block)
	content << panel_footer(footer)

	 :div, content.join("\n").html_safe, panel_options
end