Skip to content

Instantly share code, notes, and snippets.

@awestbro
Created March 12, 2017 21:52
Show Gist options
  • Save awestbro/a6f55cbb546aa95a2d0af503d72c1fc1 to your computer and use it in GitHub Desktop.
Save awestbro/a6f55cbb546aa95a2d0af503d72c1fc1 to your computer and use it in GitHub Desktop.
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">&times;</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