Sprockets::Traceur
This gem integrates traceur-rb with Sprockets (and through Sprockets, with Rails Asset Pipeline).
Installation
Add this line to your application's Gemfile:
gem 'sprockets-traceur'
And then execute:
$ bundle
Or install it yourself as:
$ gem install sprockets-traceur
Usage with Rails
-
Add
sprockets-traceurto your Gemfile. -
Add the following line in
app/assets/javascripts/application.js://= require traceur-runtime -
Add
.js.es6or.js.nextextension to the files you wish to have transpiled. -
Profit!
Usage with Sinatra/Rack
-
Add
sprockets-traceurto your Gemfile. -
Configure Rack to use Sprockets (in
config.ru):require "my_rack_application" map "/assets" do root = File.dirname(__FILE__) environment = Sprockets::Environment.new environment.append_path root + '/assets/javascripts' environment.append_path root + '/assets/stylesheets' run environment end map "/" do run MyRackApplication end
-
Add
.js.es6or.js.nextextension to the files you wish to have transipled. -
Add the following line in
assets/javascripts/application.js://= require traceur-runtime -
Reference the JS files in your views
<!-- /assets/application.js maps to /assets/javascripts/application.js[.next|.es6] --> <script type="text/javascript" src="/assets/application.js"></script>
-
Profit!
Contributing
- Fork it ( https://github.com/[my-github-username]/sprockets-traceur/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request