Packages
torch
3.2.0
6.0.0
5.6.0
5.5.0
5.4.0
5.3.2
5.3.1
5.2.0
5.1.2
5.1.1
5.1.0
5.0.0
5.0.0-rc.4
5.0.0-rc.3
5.0.0-rc.2
5.0.0-rc.1
5.0.0-rc.0
4.3.2
4.3.1
4.3.0
4.2.1
4.2.0
retired
4.1.0
4.0.0
4.0.0-rc.0
3.9.1
3.9.0
3.8.0
3.7.1
3.7.0-rc.0
3.6.4
3.6.3
3.6.2
3.6.1
3.6.0
3.5.0
3.4.1
3.4.0
3.3.1
3.3.0
3.2.1
3.2.0
3.1.0
3.0.0
2.1.0
2.0.0
2.0.0-rc.3
2.0.0-rc.2
2.0.0-rc.1
1.0.0-rc.6
1.0.0-rc.5
1.0.0-rc.4
1.0.0-rc.3
1.0.0-rc.2
1.0.0-rc.1
0.2.0-rc.5
0.2.0-rc.4
0.2.0-rc.3
0.2.0-rc.2
0.2.0-rc.1
0.1.0
Rapid admin generator for Phoenix
Current section
Files
Jump to
Current section
Files
lib/mix/tasks/torch.gen.html.ex
defmodule Mix.Tasks.Torch.Gen.Html do
@moduledoc """
Light wrapper module around `mix phx.gen.html` which generates slightly
modified HTML.
Takes all the same params as the `phx.gen.html` task.
## Example
mix torch.gen.html Accounts User users --no-schema
"""
@commands ~w[phx.gen.html phx.gen.context]
def run(args) do
if Mix.Project.umbrella?() do
Mix.raise("mix torch.gen.html can only be run inside an application directory")
end
%{format: format} = Mix.Torch.parse_config!("torch.gen.html", args)
# First, backup the projects existing templates if they exist
Enum.each(@commands, &Mix.Torch.backup_project_templates/1)
# Inject the torch templates for the generator into the priv/
# directory so they will be picked up by the Phoenix generator
Enum.each(@commands, &Mix.Torch.inject_templates(&1, format))
# Run the Phoenix generator
Mix.Task.run("phx.gen.html", args)
# Remove the injected templates from priv/ so they will not
# affect future Phoenix generator commands
Enum.each(@commands, &Mix.Torch.remove_templates/1)
# Restore the projects existing templates if present
Enum.each(@commands, &Mix.Torch.restore_project_templates/1)
Mix.shell().info("""
Ensure the following is added to your endpoint.ex:
plug(
Plug.Static,
at: "/torch",
from: {:torch, "priv/static"},
gzip: true,
cache_control_for_etags: "public, max-age=86400",
headers: [{"access-control-allow-origin", "*"}]
)
""")
Mix.shell().info("""
Also don't forget to add a link to layouts/torch.html.
<nav class="torch-nav">
<!-- nav links here -->
</nav>
""")
end
end