Packages
torch
3.6.4
6.0.0
5.6.0
5.5.0
5.4.0
5.3.2
5.3.1
5.2.0
5.1.2
5.1.1
5.1.0
5.0.0
5.0.0-rc.4
5.0.0-rc.3
5.0.0-rc.2
5.0.0-rc.1
5.0.0-rc.0
4.3.2
4.3.1
4.3.0
4.2.1
4.2.0
retired
4.1.0
4.0.0
4.0.0-rc.0
3.9.1
3.9.0
3.8.0
3.7.1
3.7.0-rc.0
3.6.4
3.6.3
3.6.2
3.6.1
3.6.0
3.5.0
3.4.1
3.4.0
3.3.1
3.3.0
3.2.1
3.2.0
3.1.0
3.0.0
2.1.0
2.0.0
2.0.0-rc.3
2.0.0-rc.2
2.0.0-rc.1
1.0.0-rc.6
1.0.0-rc.5
1.0.0-rc.4
1.0.0-rc.3
1.0.0-rc.2
1.0.0-rc.1
0.2.0-rc.5
0.2.0-rc.4
0.2.0-rc.3
0.2.0-rc.2
0.2.0-rc.1
0.1.0
Rapid admin generator for Phoenix
Current section
Files
Jump to
Current section
Files
lib/torch/views/flash_view.ex
defmodule Torch.FlashView do
@moduledoc """
Contains functions for dealing with flash messages.
"""
use Phoenix.View, root: "lib/torch/templates"
use Phoenix.HTML
import Phoenix.Controller, only: [get_flash: 2]
@doc """
Returns a formatted flash message of the given type.
## Parameters
- `conn`: The current `Plug.Conn`.
- `type`: The flash type, such as `:error`.
## Example
iex> conn = %Plug.Conn{private: %{phoenix_flash: %{"error" => "Error Message"}}}
...> flash_message(conn, "error") |> safe_to_string()
"<p class=\\"torch-flash error\\">Error Message <button class='torch-flash-close'>x</button></p>"
"""
@spec flash_message(Plug.Conn.t(), type :: atom | String.t()) :: Phoenix.HTML.safe()
def flash_message(conn, type) do
message = get_flash(conn, type)
if message do
content_tag :p, class: "torch-flash #{type}" do
raw("#{message} <button class='torch-flash-close'>x</button>")
end
end
end
end