Created
March 12, 2017 21:52
-
-
Save awestbro/a6f55cbb546aa95a2d0af503d72c1fc1 to your computer and use it in GitHub Desktop.
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
defmodule Myproject.LayoutView do | |
use Myproject.Web, :view | |
defp render_flash(type, message) do | |
~E""" | |
<div class="alert alert-<%= type %>" role="alert"> | |
<%= message %> | |
<button type="button" class="close" data-dismiss="alert" aria-label="Close"> | |
<span aria-hidden="true">×</span> | |
</button> | |
</div> | |
""" | |
end | |
def show_flash(conn) do | |
case get_flash(conn) do | |
%{"info" => msg} -> | |
render_flash("info", msg) | |
%{"error" => msg} -> | |
render_flash("danger", msg) | |
_ -> | |
"" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment