Current section
Files
Jump to
Current section
Files
lib/render.ex
defmodule UltraPlug.Render do
@moduledoc """
Renders the template.
## Options
- **template:** defaults to "index.html".
- **assigns:** overrides conn.assigns in Phoenix.
- **render:** defaults to [Phoenix.Controller.render/3](https://hexdocs.pm/phoenix/Phoenix.Controller.html#render/3).
"""
use UltraPlug, return_error_as_tuple: true
def init(opts) do
%{
template: Keyword.get(opts, :template, "index.html"),
assigns: Keyword.get(opts, :assigns, %{}),
render: Keyword.get(opts, :render, &Phoenix.Controller.render/3)
}
end
def call(conn, %{template: template, assigns: assigns, render: render}) do
render.(conn, template, assigns)
end
end