Created
August 15, 2012 09:30
-
-
Save mamantoha/3358074 to your computer and use it in GitHub Desktop.
sinatra-flash and bootstrap alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Exactly what I was looking for, legend, thanks!