This repository has been archived on 2023-08-07. You can view files and clone it, but cannot push or open issues or pull requests.
temple/lib/mix/tasks/temple.gen.layout.ex
2020-01-07 23:44:39 -05:00

32 lines
851 B
Elixir

if Code.ensure_loaded?(Mix.Phoenix) do
defmodule Mix.Tasks.Temple.Gen.Layout do
use Mix.Task
@shortdoc "Generates a default Phoenix layout file in Temple"
@moduledoc """
Generates a Phoenix layout file in Temple.
mix temple.gen.layout
"""
def run(_args) do
context_app = Mix.Phoenix.context_app()
web_prefix = Mix.Phoenix.web_path(context_app)
binding = [application_module: Mix.Phoenix.base()]
Mix.Phoenix.copy_from(temple_paths(), "priv/templates/temple.gen.layout", binding, [
{:eex, "app.html.eex", "#{web_prefix}/templates/layout/app.html.exs"}
])
instructions = """
A new #{web_prefix}/templates/layout/app.html.exs file was generated.
"""
Mix.shell().info(instructions)
end
defp temple_paths do
[".", :temple]
end
end
end