Skip to content

Instantly share code, notes, and snippets.

@mamantoha
Created August 15, 2012 09:30
Show Gist options
  • 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
@omensinger
Copy link

Tnx!

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