Skip to content

View helpers for incorporating Elm modules into Rails views

License

Notifications You must be signed in to change notification settings

nvaldes/elm-rails

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

elm-rails

elm-rails makes it easy to use Elm modules in your Ruby on Rails applications. This project was heavily inspired by react-rails.

Compatibility

This gem is tested against Ruby 2.2 and 2.3, and Rails versions 4.2.7 and 5.0. It may work on other versions, and if you want to open a PR adding tests against those versions they would be welcome.

Installation

  1. Add elm-rails to your Gemfile and run bundle install

    gem "elm-rails"
  2. Create a new directory to house all Elm modules

    mkdir app/assets/elm
  3. Update .gitignore to ignore elm files

    /elm-stuff
    

Usage

  1. Define your elm modules in the app/assets/elm directory.

    app/assets/elm/Hello.elm

    module Hello exposing (..)
    
    import Html exposing (text)
    
    port noun : String
    
    main =
      text ("Hello " ++ noun)
  2. Open your app/assets/javascript.js and require your Hello.elm.

//= require Hello
  1. Use the view helper to insert your component into your view. Pass port values as a Hash.

    <h1>This is an Elm component!</h1>
    <%= elm_embed('Elm.Hello', { noun: 'World!' }) %>
  2. That's it!

Configuration

There is nothing to configure, but you should have Elm installed in your system and elm-make must be availble in your path.

About

View helpers for incorporating Elm modules into Rails views

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 82.0%
  • HTML 14.9%
  • CSS 2.1%
  • Other 1.0%