Opal-Browser - Client side web development in pure Ruby, using Opal

Gem Version Code Climate Build Status Join Chat Stack Overflow Documentation

This library aims to be a full-blown wrapper for all the browser API as defined by HTML5.

It provides a very JQuery-like interface to DOM, but itself it doesn’t use nor require JQuery nor opal-jquery (which is an alternative library for interfacing the web browser). The main difference though is that Opal-Browser goes far beyond what JQuery does.



“by source ‘https://rubygems.org/’

gem ‘opal-browser’

Server side (config.ru, Rakefile, Rails, Sinatra, Roda, etc. - not needed for static compilation)

“by require ‘opal-browser’

Your server code here

Browser side

“by require ‘opal’ require ‘native’ require ‘promise’ require ‘browser/setup/full’

Your Opal code here

$document.body « “Hello world!”

Static Compile Opal + Opal-Browser library

“sh bundle exec opal -c -q opal-browser -p native -p promise -p browser/setup/full -e ‘#’ -E > opal-browser.js

Static Compile your application

“sh bundle exec opal -Oc -s opal -s native -s promise -s browser/setup/full app/application.rb > application.js

And load it in HTML!

“ml <!DOCTYPE html>

My Application