analytics/lib/plausible_web/controllers/helpers.ex
Vini Brasil 257fa16cdc
Simplify Phoenix error template (#2913)
* Simplify Phoenix error template

* Test tracking script is not included in error pages

* Test tracking script is not rendered in error templates

* Rename error layout and remove unnecessary HTML boilerplate

* Add layout setting to errors rendered without exceptions

* Add skip_plausible_tracking option to more pages
2023-05-16 10:52:17 +02:00

22 lines
580 B
Elixir

defmodule PlausibleWeb.ControllerHelpers do
import Plug.Conn
import Phoenix.Controller
def render_error(conn, status, message) do
conn
|> put_status(status)
|> put_view(PlausibleWeb.ErrorView)
|> render("#{status}.html", message: message, layout: error_layout())
end
def render_error(conn, status) do
conn
|> put_status(status)
|> put_view(PlausibleWeb.ErrorView)
|> render("#{status}.html", layout: error_layout())
end
defp error_layout,
do: Application.get_env(:plausible, PlausibleWeb.Endpoint)[:render_errors][:layout]
end