Phoenix Elm Scaffold v0.2.1 Mix.Tasks.Phx.Gen.Elm
Generates an elm app inside a Phoenix (1.3) app with the necessary scaffolding
adds:
- elm files (
Main
,Model
,View
,Update
) - an embed script
elm-package.json
- A phoenix
controller
,view
andtemplate
- an
elm-test
setup
to run the generator:
> mix phx.gen.elm
then follow post install instructions:
- add the following to the
plugins
section of yourbrunch-config.js
elmBrunch: {
mainModules: ['elm/Main.elm'],
outputFile: 'elm.js',
outputFolder: '../assets/js',
makeParameters: ['--debug'] // optional debugger for development
}
- add
elm
to thewatched
array in yourbrunch-config.js
You may also want to add/elm\.js/
to the babel ignore pattern to speed up compilation
babel: {
ignore: [/vendor/, /elm.js/]
}
- in your
app.js
file add the following
import ElmApp from './elm.js'
import elmEmbed from './elm-embed.js'
elmEmbed.init(ElmApp)
- and finally in your
router.ex
file add
get "/path-to-elm-app", ElmController, :index
Summary
Functions
A task needs to implement run
which receives
a list of command line args.
Callback implementation for Mix.Task.run/1
.