Project

es6-rails

0.01
No commit activity in last 3 years
No release in over 3 years
Enables use of ES6 in assets, views and inline.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 0.7.0, ~> 0.7
< 5.0, >= 4.0
>= 3.0.0, ~> 3.0
>= 0.8.1, ~> 0.8
 Project Readme

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