ブラウザ上の ruby.wasm で HTMLElement を継承してクラスをつくるとカスタム要素を作成できる。
<!DOCTYPE html>
<html>
<script 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/tmtm/[email protected]/lib/htmlelement.rb"></script>
<script type="text/ruby">
class HogeHoge < HTMLElement
def initialize
self.text_content = 'hoge hoge'
self.style.color = 'red'
end
end
</script>
<body>
<hoge-hoge></hoge-hoge>
</body>
</html>
MIT