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 and template
  • an elm-test setup

to run the generator:

> mix phx.gen.elm

then follow post install instructions:

  1. add the following to the plugins section of your brunch-config.js

    elmBrunch: {
      elmFolder: '.',
      mainModules: ['elm/Main.elm'],
      outputFile: 'elm.js',
      outputFolder: '../assets/js',
      makeParameters: ['--debug'] // optional debugger for development
    }
  2. add elm to the watched array in your brunch-config.js You may also want to add /elm\.js/ to the babel ignore pattern to speed up compilation

    babel: {
      ignore: [/vendor/, /elm.js/]
    }
  3. in your app.js file add the following

    import ElmApp from './elm.js'
    import elmEmbed from './elm-embed.js'
    
    elmEmbed.init(ElmApp)
  4. 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

Functions

run(argv)

A task needs to implement run which receives a list of command line args.

Callback implementation for Mix.Task.run/1.