Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Ruby in the browser.
C++ JavaScript C Ruby Python Objective-C Other
branch: decaf

This branch is 100 commits ahead, 29258 commits behind WebKit:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
Examples Rollback 88521
LayoutTests
ManualTests
PerformanceTests [CSS Regions] Add performance tests
Source Using delete instead of free.
Tools
WebKit.xcworkspace Added a project and a scheme to build a Decaf binary.
WebKitLibraries Unreviewed. Rollout r146818.
Websites EWS bubbles need more space
.dir-locals.el emacs: unreviewed. add settings for editing js files.
.gitattributes Tell git-archive to not export .gitattributes and .gitignore
.gitignore
.qmake.conf
CMakeLists.txt [CMake] Add minimum version information for tool dependencies
ChangeLog [EFL] Enable user-select:all for EFL port
ChangeLog-2012-05-22 .: == Rolled over to ChangeLog-2012-05-22 ==
GNUmakefile.am [GTK] Build GTK-specific, non-layer-violating source code into WebCor…
Makefile Makefiles should work for arbitrary SDKs and architectures on Apple p…
Makefile.shared Makefiles should work for arbitrary SDKs and architectures on Apple p…
README.md Update README.md
WebKit.pro
autogen.sh [GTK] Move feature overriding to the configure phase
configure.ac [GTK] Enable translations for WebKit2
wscript Merge SVGStylable into SVGStyledElement

README.md

Decaf

Decaf is a modification of WebKit that runs Ruby in the browser. Use Ruby to access the DOM, work with the web standards, and even print to the inspector. Now, you can build an entire web application in Ruby instead of JavaScript.

To use Ruby in the browser, either download a binary or build it yourself.

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

Using Ruby in the Browser

The same web platform APIs used by JavaScript are available in Ruby. If you're not familiar with JavaScript and the DOM, then check out these resources:

Differences from JavaScript

There are a few major differences between the APIs in JavaScript and Ruby.

  • 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. For example:
# Ruby with implicit blocks
$window.set_timeout(1000) { console.log('Hello!') }
$window.onload do |event|
  console.log('The window loaded.')
end

# Ruby with explicit Procs
$window.set_timeout(Proc.new { console.log('Hello!') }, 1000)
$window.onload = Proc.new do |event|
  console.log('The window loaded.')
end

Final Notes

If you find any problems, then please report them in the issues section.

Something went wrong with that request. Please try again.