Created
May 10, 2018 21:06
-
-
Save willywg/b78be8e547e974dc622dd0d2a01fa017 to your computer and use it in GitHub Desktop.
Rails flash messages helper for bootstrap 4 with slim
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
- flash.each do |type, msg| | |
div class=("alert #{bootstrap_class_for_flash(type)} alert-dismissable fade show") | |
= msg | |
button.close data-dismiss="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 BootstrapFlashMessageHelper | |
FLASH_TYPES = { | |
'success' => 'alert-success', | |
'error' => 'alert-danger', | |
'alert' => 'alert-warning', | |
'notice' => 'alert-info' | |
} | |
def bootstrap_class_for_flash(flash_type) | |
FLASH_TYPES[flash_type] || flash_type.to_s | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment