0.1.0 • Published 2 years ago

rbscript v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

RbScript

npm

Run Ruby in your HTML.

<script type="text/ruby">
  puts 'Hello, world!'
</script>

This library is built using ruby.wasm, and greatly inspired by PyScript.

Installation

Import the RbScript file to your HTML:

<script defer src="https://cdn.jsdelivr.net/npm/rbscript/dist/rbscript.umd.js"></script>

Feature

Ruby code execution

You can execute Ruby codes written in the <script> tag with text/ruby type.

<script type="text/ruby" src="./greeting.rb"></script>
<script type="text/ruby">
  puts 'Hi!'
</script>

Event handling

You can specify callback functions using data attributes whose name starts with rb-.

<button data-rb-onclick="greeting">Hi!</button>

<script type="text/ruby">
  def greeting(event)
    puts 'Hi!'
  end
</script>

License

Licensed under the MIT license.