Skip to content

This is a prototype of a front-end framework made in Ruby.

Notifications You must be signed in to change notification settings

ledsun/orbital_ring

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

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/head-wasm-wasi@2.5.0-2024-04-02-a/dist/browser.script.iife.js"></script>
<script type="text/ruby" src="https://cdn.jsdelivr.net/gh/ledsun/orbital_ring@0.0.1/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.

About

This is a prototype of a front-end framework made in Ruby.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages