Closed stugol closed 5 years ago
Did you require 'browser'
?
Yup.
@stugol is it in a haml filter?
Yup. I have the following filter code:
module Haml::Filters::Opal
include Haml::Filters::Base
def render_with_options ruby, options
text = ::Opal.compile(ruby)
type = (options[:format] == :html5) ? '' : " type=#{options[:attr_wrapper]}text/javascript#{options[:attr_wrapper]}"
text.rstrip!
text.gsub!("\n", "\n ")
<<HTML
<script#{type}>
//<![CDATA[
#{text}
//]]>
</script>
HTML
end
end
This looks like there's no browser
loaded on the browser side, only opal-browser
server side. You would either need to add require "browser"
in some HAML filter or add some <script src='opal-browser.js'></script>
with a pre-compiled opal-browser (November 2019: I don't think there are any up-to-date pre-compiled distributions of opal-browser as of yet, we will probably do it with the next release)
I'm closing this issue in a process of tidying up issues of this project. Please feel free to reopen it if it is still relevant :)
I'm trying to run code similar to the example:
I get
undefined method 'ready' for nil
.Similarly:
I get
undefined method 'alert' for main