Giter VIP home page Giter VIP logo

es6-rails's Introduction

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 People

Contributors

b264 avatar lengshuiyulangcn avatar razorcd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

es6-rails's Issues

Allow another file extensions than .es6

I actually work with a old version of angular that cannot understand .es6 file in local. (The gem work very well when I deploy the app by the assets pipeline)

It will be great if you can allow the file extension ".es6.js" so I will be able to test my app in local.

Thanks for your work and for your time.

gem compatibility with rails 5

Hi,

In Rails 5, we can't use es6 in js views, so this gem could be useful. Do you think it would be possible to adapt it to work with rails >= 5.0 ?

Thanks!

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.