Run Ruby in the browser with Decaf, a fork of WebKit.

Andrew Thorp Andrew Thorp

Decaf, from Tim Mahoney is a fork of WebKit that allows you to run Ruby in the browser. A simple example from the README:

<script type='text/ruby'>
  window.onload do
    introduction = document.create_element('p')
    introduction.inner_text = 'Hello, world!'

It only works on the Mac right now, and there are a few other gotcha's to keep in mind:

  • In Ruby, methods and attributes are specified in underscore_case instead of camelCase.
  • The window variable is accessible from only the top-most scope. Elsewhere you can use the global $window.
  • Ruby accepts Procs and blocks as callbacks and listeners. View an example.

You can go to the project homepage, get the latest release or view the source on GitHub.

0:00 / 0:00