Skip to content

Latest commit

 

History

History
65 lines (44 loc) · 1.52 KB

README.md

File metadata and controls

65 lines (44 loc) · 1.52 KB

Orbital Ring

This is a proof of concept for a front-end framework written in Ruby. It is intended to work with ruby.wasm.

Features

  • Auto loading
  • Rendering
  • Event binding

Usage

<script defer
    src="https://cdn.jsdelivr.net/npm/@ruby/[email protected]/dist/browser.script.iife.js"></script>
<script type="text/ruby" src="https://cdn.jsdelivr.net/gh/ledsun/[email protected]/orbital_ring.rb"></script>

Auto loading

Load the Ruby script that defines the constants from the app_root directory. For example, when the App class is called, ./app_root/app.rb is load.

To enable auto loading, execute the following function:

OrbitalRing::Loader.setup

Rendering

The render function can be used to render HTML using erb.html file as a template. For example:

render :page, collection: pages

To use the render function, include OrbitalRing::Renderer module.

include OrbitalRing::Renderer

Place the template file in the app_root/templates directory.

Event binding

The OrbitalRing::Routes.draw function can be used to bind events like jQuery's on function. For example:

OrbitalRing::Routes.draw do
  click '.confirm_button', to: ClickHandler, params: { view: view }
end

This is similar to the following example in jQuery:

$('#app_root').on('click', '.confirm_button', function() {
  // Do something.
})

The HTML element to which the event is bound must be a child element of an HTML element whose id is app_root.