Current section

Files

Jump to
ultra_plug lib render.ex
Raw

lib/render.ex

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