Skip to content

Commit

Permalink
Remove code checking for phx < 1.6
Browse files Browse the repository at this point in the history
Only support heex now also, since we only support phx 1.6+
  • Loading branch information
cpjolicoeur committed Apr 26, 2022
1 parent 56a70cd commit b3c9b80
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
11 changes: 4 additions & 7 deletions lib/mix/tasks/torch.gen.html.ex
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,11 @@ defmodule Mix.Tasks.Torch.Gen.Html do

Mix.Torch.ensure_phoenix_is_loaded!("torch.gen.html")

phoenix_version = to_string(Application.spec(:phoenix, :vsn))

# Check for Phoenix 1.6+ with Phoenix.HTML 3+ and Heex
template_format =
cond do
format == "slime" -> format
Version.match?(phoenix_version, ">= 1.6.0-rc.0", allow_pre: true) -> "heex"
true -> "eex"
if format == "slime" do
format
else
"heex"
end

# First, backup the projects existing templates if they exist
Expand Down
4 changes: 0 additions & 4 deletions priv/templates/common/phx.gen.html/controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@ defmodule <%= inspect context.web_module %>.<%= inspect Module.concat(schema.web
alias <%= inspect context.module %>
alias <%= inspect schema.module %>

<%= if Version.match?(to_string(Application.spec(:phoenix, :vsn)), "< 1.5.0") do %>
plug(:put_layout, {<%= inspect context.web_module %>.LayoutView, "torch.html"})
<% else %>
plug(:put_root_layout, {<%= inspect context.web_module %>.LayoutView, "torch.html"})
plug(:put_layout, false)
<% end %>

def index(conn, params) do
case <%= inspect context.alias %>.paginate_<%= schema.plural %>(params) do
Expand Down

0 comments on commit b3c9b80

Please sign in to comment.