Git Product home page Git Product logo

elm-rails's Introduction

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/javascripts/application.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

By default, elm-rails will use the version of elm-make available in your system path. If you wish, you may configure this in an initializer: config/initializers/elm_rails.rb erb Elm::Rails.elm_make_path = "bin/elm-make"

elm-rails's People

Contributors

ankane avatar botandrose-machine avatar fbonetti avatar lsimoneau avatar mariochavez avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.