andrewMacmurray / phoenix-elm-scaffold

Mix Task to generate an elm app inside a Phoenix (1.3) app
https://hexdocs.pm/phoenix_elm_scaffold/Mix.Tasks.Phx.Gen.Elm.html
BSD 3-Clause "New" or "Revised" License
37 stars 7 forks source link

Generator mis-names modules #6

Closed RobertSwirsky closed 7 years ago

RobertSwirsky commented 7 years ago
== Compilation error on file lib/ui_x_web/views/elm_view.ex ==
** (CompileError) lib/ui_x_web/views/elm_view.ex:2: module UiX.Web is not loaded and could not be found
    (elixir) expanding macro: Kernel.use/2
    lib/ui_x_web/views/elm_view.ex:2: UiX.Web.ElmView (module)
    (elixir) lib/kernel/parallel_compiler.ex:117: anonymous fn/4 in Kernel.ParallelCompiler.spawn_compilers/1

It should be UiXWeb (given my project name) Not sure where the dot is coming from. I manually changed it and it's happy

andrewMacmurray commented 7 years ago

@chatterbeak thanks, will take a look at this

andrewMacmurray commented 7 years ago

@chatterbeak was the atom for your application :ui_x_web?

RobertSwirsky commented 7 years ago

My project was called ui_x I think that's what the problem was....

andrewMacmurray commented 7 years ago

Ah, so your project was :ui_x but the module name for something like a controller would have been UiXWeb.Web.PageController? Maybe I could add a command line option for manually naming the web module and application name

colecullen commented 7 years ago

Thanks for creating this mix item. I was in the process of doing the phoenix/elm integration when I found your contribution.

I also encountered the issue entered by chatterbeak. It seems that you may have an extra dot "." in a couple of sources used to generate the project.

Specifically:

~/projects//deps/phoenix_elm_scaffold/priv/templates/phx.gen.elm/controllers/elm_controller.ex

defmodule <%= app_name %>.Web.ElmController do use <%= app_name %>.Web, :controller

def index(conn, _params) do render conn, "index.html" end end

and,

~/projects//deps/phoenix_elm_scaffold/views/elm_view.ex

defmodule <%= app_name %>.Web.ElmView do use <%= app_name %>.Web, :view end

The dot "." after "<%= app_name %>" in both modules are resulting in a different name than that generated in the rest of the app files. I removed these dots from these modules in the phx.gen.elm mix project and everything then build and executed without error. I would be happy to make these changes in a pull request (I am fairly new to git).

andrewMacmurray commented 7 years ago

@colecullen hey, sorry has taken me a while to take a look at this, this looks good, will merge in

andrewMacmurray commented 7 years ago

closed with pr #7