Skip to content
This repository

Write Ruby. Run JavaScript. The new Red is here.

Red takes the Ruby you write and turns it into JavaScript for your browser.

The all-new Red is a Ruby-to-JavaScript transliterator backed by a custom ruby.js library designed to let your code run in the browser exactly the way Ruby would run on your machine. The JavaScript output is optimized to contain only the fraction of the ruby.js source library needed to run your code.

What does this mean for today’s Ruby developer? Simple. You don’t need to learn JavaScript.


To get Red working, install the rubygem.

sudo gem install red

Take Red for a Spin

Create the files test.html and in the same directory:

 # test.html
 1| <html>
 2|   <head>
 3|     <script type="text/javascript" src="test.js"></script>
 4|   </head>
 5|   <body></body>
 6| </html>

 1| class Test
 2|   attr_accessor :my_var
 4|   def initialize(arg)
 5|     @my_var = arg
 6|   end
 7| end
 9| test ="It worked!")
10| puts test
11| puts test.my_var

Now execute red test on the command line. Open test.html and check the output in Firebug and you’ll see:

It worked!

For comparison, execute ruby on the command line, and you’ll find the output to be equivalent.

Red for Rails

Red integrates seamlessly with Rails. Check out the Tutorial: Red for Rails, or navigate to your project and run:

red -r

More Help

Have a question? Start a discussion at the Red google group, or check if your question has already been answered. Read the comprehensive RDoc for Red for help on individual methods and classes.

Bugs / Issues

Have a problem? Tell us about it. Submit a ticket to the project page at Lighthouse.

Something went wrong with that request. Please try again.