0.01
Low commit activity in last 3 years
No release in over a year
Allows you compile Elm files and write to a file or stdout
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
~> 3.0
>= 0
 Project Readme

elm-compiler

Build Status

Ruby wrapper for the Elm language compiler.

The project is heavily inspired by the sprockets-elm repository, written by rtfeldman.

Installation

Install the Elm platform:

http://elm-lang.org/install

Add this line to your application's Gemfile:

gem 'elm-compiler'

And then execute:

$ bundle

Or install it yourself as:

$ gem install elm-compiler

Usage

NOTE: Make sure Elm is installed. If the elm executable can't be found in the current PATH or via the elm_path option, the exception Elm::Compiler::ExecutableNotFound will be thrown.

Elm::Compiler.compile(elm_files, output_path: nil, elm_path: nil, debug: false, esm: false)
  • 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 the elm executable. If left blank, the executable will be looked up in the current PATH, if that cannot be found, it will download elm to /tmp/elm-0.19.1 and use that.
  • debug: Whether or not to compile in debug mode. Default is false.
  • esm: Whether or not to rewrite the compilation result into ESM format. Default is false. Can also be set on a global basis by Elm::Compiler.elm = true

Examples

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")

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/fbonetti/elm-compiler.

License

The gem is available as open source under the terms of the MIT License.