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