GithubHelp home page GithubHelp logo

r00k / elm-rails Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fbonetti/elm-rails

1.0 1.0 0.0 11 KB

View helpers for incorporating Elm modules into Rails views

License: MIT License

Ruby 80.26% HTML 19.74%

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.

Installation

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

    gem "elm-rails"
  2. Add the elm_modules asset to your application.js manifest file

    //= require elm_modules
  3. Create a new directory to house all Elm modules

    mkdir app/assets/elm
  4. Disable asset caching in config/environments/development.rb

    config.assets.configure do |env|
      env.cache = ActiveSupport::Cache.lookup_store(:null_store)
    end
  5. Update .gitignore to ignore elm files

    /elm-stuff
    

Usage

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

    app/assets/Hello.elm

    module Hello where
    
    import Graphics.Element exposing (show)
    
    port noun : String
    
    main =
      show ("Hello " ++ noun)
  2. 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!' }) %>
  3. That's it!

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.