An open API service indexing awesome lists of open source software.

https://github.com/woxtu/rbscript

Run Ruby in your HTML
https://github.com/woxtu/rbscript

ruby

Last synced: 5 months ago
JSON representation

Run Ruby in your HTML

Awesome Lists containing this project

README

          

# RbScript

[![npm](https://img.shields.io/npm/v/rbscript.svg?style=flat-square)](https://www.npmjs.com/package/rbscript)

Run Ruby in your HTML.

```html

puts 'Hello, world!'

```

This library is built using [ruby.wasm](https://github.com/ruby/ruby.wasm), and greatly inspired by [PyScript](https://pyscript.net/).

## Installation

Import the RbScript file to your HTML:

```html

```

## Feature

### Ruby code execution

You can execute Ruby codes written in the `` tag with `text/ruby` type.

```html
<script type="text/ruby" src="./greeting.rb">
```

```html

puts 'Hi!'

```

### Event handling

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

```html
Hi!

def greeting(event)
puts 'Hi!'
end

```

## License

Licensed under the MIT license.