View Source Torch.FlashView (Torch v5.0.0-rc.2)
Contains functions for dealing with flash messages.
Link to this section Summary
Functions
Returns a formatted flash message of the given type.
Returns a formatted group of all flash messages available.
Link to this section Functions
@spec flash_message(%{assigns: %{flash: map()}}, type :: atom() | String.t()) :: Phoenix.HTML.safe()
Returns a formatted flash message of the given type.
parameters
Parameters
assigns
: The currentPlug.Conn.assigns
map.type
: The flash type, such as:error
.
example
Example
iex> conn = %Plug.Conn{assigns: %{flash: %{"error" => "Error Message"}}}
...> flash_message(conn.assigns, "error") |> Phoenix.HTML.Safe.to_iodata() |> IO.iodata_to_binary()
"<p class=\"torch-flash error\">Error Message <button class=\"torch-flash-close\">x</button></p>"
@spec flash_messages(%{assigns: %{flash: map()}}) :: Phoenix.LiveView.Rendered.t()
Returns a formatted group of all flash messages available.
parameters
Parameters
assigns
: The currentPlug.Conn.assigns
map.
example
Example
iex> conn = %Plug.Conn{assigns: %{flash: %{"error" => "Error Message", "info" => "Info Message", "invalid" => "Invalid flash key"}}}
...> flash_messages(conn.assigns) |> Phoenix.HTML.Safe.to_iodata() |> IO.iodata_to_binary()
"<section id=\"torch-flash-messages\">\n <div class=\"torch-container\">\n <p class=\"torch-flash error\">Error Message <button class=\"torch-flash-close\">x</button></p>\n <p class=\"torch-flash info\">Info Message <button class=\"torch-flash-close\">x</button></p>\n \n </div>\n</section>"