diff --git a/lib/ha_handler.ex b/lib/ha_handler.ex index 2700fc0..e7855f5 100644 --- a/lib/ha_handler.ex +++ b/lib/ha_handler.ex @@ -15,6 +15,7 @@ defmodule HAHandler do def acme_challenge_path, do: Application.get_env(@otp_app, :acme_challenge_path) def static_path(), do: Application.app_dir(@otp_app, "priv/static/") + def template_dir(), do: "lib/ha_handler/web/templates" def otp_app(), do: @otp_app def version(), do: @version diff --git a/lib/ha_handler/web/controller.ex b/lib/ha_handler/web/controller.ex index 448af9c..5d1f3ee 100644 --- a/lib/ha_handler/web/controller.ex +++ b/lib/ha_handler/web/controller.ex @@ -3,12 +3,13 @@ defmodule HAHandler.Web.Controller do alias HAHandler.{HAProxy, PGSQL} - @templates_dir "lib/ha_handler/web/templates" + @template_dir "lib/ha_handler/web/templates" + @index_template EEx.compile_file( + Path.join(@template_dir, "index.html.eex") + ) defp render(conn, template, assigns) do - template_path = Path.join(@templates_dir, template) - quoted = EEx.compile_file(template_path) - {body, _binding} = Code.eval_quoted(quoted, assigns) + {body, _binding} = Code.eval_quoted(template, assigns) conn |> put_resp_content_type("text/html") @@ -28,6 +29,6 @@ defmodule HAHandler.Web.Controller do version: HAHandler.version(), env: HAHandler.env() ] - render(conn, "index.html.eex", assigns) + render(conn, @index_template, assigns) end end