Skip to content

Instantly share code, notes, and snippets.

@mamantoha
Created August 15, 2012 09:30
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mamantoha/3358074 to your computer and use it in GitHub Desktop.
Save mamantoha/3358074 to your computer and use it in GitHub Desktop.
sinatra-flash and bootstrap alert
module Sinatra
module Flash
module Style
def styled_flash(key=:flash)
return "" if flash(key).empty?
id = (key == :flash ? "flash" : "flash_#{key}")
close = '<a class="close" data-dismiss="alert" href="#">×</a>'
messages = flash(key).collect {|message| " <div class='alert alert-#{message[0]}'>#{close}\n #{message[1]}</div>\n"}
"<div id='#{id}'>\n" + messages.join + "</div>"
end
end
end
end
@neiled
Copy link

neiled commented Mar 6, 2013

Exactly what I was looking for, legend, thanks!

@omensinger
Copy link

Tnx!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment