Skip to content

Instantly share code, notes, and snippets.

@borgand
Created May 8, 2012 11:32
Show Gist options
  • Save borgand/2634361 to your computer and use it in GitHub Desktop.
Save borgand/2634361 to your computer and use it in GitHub Desktop.
Rails HAML helper method to display Twitter Bootstrap alert boxes
module ApplicationHelper
# Display alert box with message or optional block
def alert_box(alert_type = :info)
haml_tag :div, :class => 'row-fluid' do
haml_tag :div, :class => "span9 alert alert-#{alert_type}" do
haml_tag :a, '×', :class => 'close', :'data-dismiss' => 'alert'
block_given? ? yield : msg
end
end
end
end
- alert_box :info do
%strong Notice:
You can put what ever HAML in here.
%br
And even put in in multiple lines
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment