Code Monkey home page Code Monkey logo

Use ES6 in Rails everywhere

ES6 (EcmaScript 2015) adapter for Rails. It transpiles all ES6 code to ES5 (JavaScript) using ruby-babel-transpiler.

Write ES6 in:

  • assets (supported extensions: .es6, .es6.js)
  • views as remote es6 script. (supported extensions: .es6)
  • views as inline html

Example app

es6-rails-example

Use

Assets:

  • add ES6 code as .es6 or .es6.js files in /app/assets/javascripts/
  • or use rails generator: rails g es6:assets my_file

ES6 views:

  • add ES6 code as .es6 files in /app/views/ (you can include erb code too)

HTML views:

  • add ES6 code in any HTML(ERB) file in /app/views/ using: <%= es6_transform do %> .. es6 code .. <% end %>

E.g.:

<script>
  <%= es6_transform do %>
    let square = x => x * x;
    console.log(square(5));
  <% end %>
</script>

Installation

Add the es6-rails to your Gemfile:

gem 'es6-rails'

Test

  • for testing the gem please run the tests in the es6-rails-example example application with tests all use cases

Publish

  • gem build es6-rails.gemspec
  • gem push es6-rails-0.3.5.gem

es6-rails's Projects

es6-rails icon es6-rails

ES6 adapter for Rails. Enables use of ES6 in assets, views and inline.

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.