Module: Sinatra::Flash::Style
- Defined in:
- lib/sinatra/flash/style.rb
Instance Method Summary collapse
-
#styled_flash(key = :flash) ⇒ String
A view helper for rendering flash messages to HTML with reasonable CSS structure.
Instance Method Details
#styled_flash(key = :flash) ⇒ String
A view helper for rendering flash messages to HTML with reasonable CSS structure. Handles multiple flash messages in one request. Wraps them in a <div> tag with id #flash containing a <div> for each message with classes of .flash and the message type. E.g.:
It is your responsibility to style these classes the way you want in your stylesheets.
@param[optional, String, Symbol] key Specifies which flash collection you want to display.
If you use this, the collection key will be appended to the top-level div id (e.g.,
'flash_login' if you pass a key of :login).
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/sinatra/flash/style.rb', line 22 def styled_flash(key=:flash) return "" if flash(key).empty? id = (key == :flash ? "flash" : "flash_#{key}") = flash(key).collect {|| " <div class='flash #{[0]}'>#{[1]}</div>\n"} '<div id="outer"> <div id="wrapper" > <img id="icon" src="images/info.png" alt="icon" /> <div id="iconshadow" style="-webkit-mask-box-image: url("images/info.png") 0 stretch"></div> <div id="textwrapper"> <div id="border"></div>' + .join + '</div> </div> </div>' end |