Phoenix Elm Scaffold v0.2.6 Mix.Tasks.Phx.Gen.Elm
Generates an elm app inside a Phoenix (1.3) app with the necessary scaffolding
adds:
- elm files (
Main
,Types
,State
,View
) - 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: { elmFolder: '.', 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 compilationbabel: { ignore: [/vendor/, /elm.js/] }
in your
app.js
file add the followingimport ElmApp from './elm.js' import elmEmbed from './elm-embed.js' elmEmbed.init(ElmApp)
and finally in your
router.ex
file addget "/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
.