Become ruby developer once again
`#{1} + 1`
`num + 1`
`Opal.SomeNamespace.SomeClass`
`obj.$method()`
`obj.instance_variable`
Minified | Gzipped | |
---|---|---|
Opal Runtime | 148KB | 35KB |
Sugar.js | 49KB | 18KB |
Underscore.js | 14KB | 5KB |
Any sufficiently complicated C or Fortran program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp.
Any sufficiently complicated Javascript program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Ruby.
Document.ready? do
el = Element['#id']
el.value = 'my input'
el.on(:click) do |e| e.prevent_default el.add_class('clicked') end
HTTP.get("/users.json") do |response| if response.ok? puts response.json else puts response.body end end
end
`el.resizable({
helper: "ui-resizable-helper"
});`
class Element
def resizable(options = {})
`this.resizable(#{options})`
end
end
class MyView < View
template :li do div model.name, class: 'name' end
on :click do model.name = 'Opal' end
render do el.resizable end
def initialize(options = {}) super model.on(:change) { render } end
end
Element['#container'].append MyView.new.render
class MyModel < Model
string :name integer :age
embeds :children, MyCollection
end
class MyCollection < Collection child ChildClass end