I'm currently trying to write a mix task that automates the scaffolding of an Elm app in a phoenix (v1.3)
project. It's generating all the elm files / js script to add, installing node and elm modules correctly. I'm also generating an elm_view.ex
and elm_controller.ex
that takes the name of the current otp_app
, and it outputs the files correctly like below:
defmodule PipeDream.Web.ElmController do
use PipeDream.Web, :controller
def index(conn, _params) do
render conn, "index.html"
end
end
However, when I start the server with mix phx.server
I get an error: "module PipeDream.Web.ElmController is not available"
. I've found that when I go to these files and save them the module gets picked up correctly (similar error with the elm_view.ex
).
Could this be something to do with how I'm rendering the controller
and view
templates? The templates look like this:
defmodule <%= @app_name %>.Web.ElmController do
use <%= @app_name %>.Web, :controller
def index(conn, _params) do
render conn, "index.html"
end
end
and I'm using EEx.eval_string(template_string, assigns: [app_name: app])
to add the app module name and then writing the file with Mix.Generator.create_file
Would be super grateful for any help or suggestions!