require 'opal' require 'native' require 'beryl/deserializer' require 'beryl/runtime' module Beryl class Frontend def initialize(view) @view = view end def onload(&block) `window.onload = block;` end def run onload do document = Native(`window.document`) root = document.getElementById('beryl') serialized_state = root.getAttribute('data-beryl').gsub('"', '"') state = Beryl::Deserializer.deserialize(serialized_state) Beryl::Runtime.new(root, state, @view).run end end end end