Run Ruby in the browser with Decaf, a fork of WebKit.
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!'
document.body.append_child(introduction)
end
</script>
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 ofcamelCase
. - The
window
variable is accessible from only the top-most scope. Elsewhere you can use the global$window
. - Ruby accepts
Procs
andblocks
as callbacks and listeners. View an example.
You can go to the project homepage, get the latest release or view the source on GitHub.
Discussion
Sign in or Join to comment or subscribe