Ruby wrapper for the Elm language compiler.
The project is heavily inspired by the sprockets-elm repository, written by rtfeldman.
Install the Elm platform:
Add this line to your application's Gemfile:
gem 'elm-compiler'
And then execute:
$ bundle
Or install it yourself as:
$ gem install elm-compiler
NOTE: Make sure Elm is installed. If the
elm
executable can't be found in the currentPATH
or via theelm_path
option, the exceptionElm::Compiler::ExecutableNotFound
will be thrown.
Elm::Compiler.compile(elm_files, output_path: nil, elm_path: nil)
elm_files
: Accepts a single file path or an array of file paths.output_path
: Path to the output file. If left blank, the compiled Javascript will be returned as a string.elm_path
: Path to theelm
executable. If left blank, the executable will be looked up in the currentPATH
.
Compile to string of Javascript:
Elm::Compiler.compile("Clock.elm")
Compile multiple files to a string of Javascript:
Elm::Compiler.compile(["Clock.elm", "Counter.elm"])
Compile to file:
Elm::Compiler.compile("Clock.elm", output_path: "elm.js")
Compile multiple files to file:
Elm::Compiler.compile(["Clock.elm", "Counter.elm"], output_path: "elm.js")
Bug reports and pull requests are welcome on GitHub at https://github.com/fbonetti/elm-compiler.
The gem is available as open source under the terms of the MIT License.