The Math module is in Opal's stdlib and isn't included in the default runtime (as far as I can tell). Depending on your deployment context, it might be easiest to build the Math module (Opal::Builder.build('math')) into a file. For your specific example, though, you can just use the JS PI...
Not at the moment. There's an open PR that should fix this, but it's kinda stalled https://github.com/opal/opal/pull/657 Would need someone to pick up and complete the work that was started. ...
html,ruby,pagination,opalrb,voltrb
You could for example use the following routes: client '/books', controller: 'books', action: 'index' client '/books/{{ genre }}/{{ title }}', controller: 'books', action: 'template' This will route both requests to the books controller. And it will make the genre and title available via the params collection in the template controller...
If someone will face that issue: you should render js file with .opal extension like remote_reply.js.opal and that will do.
I'm guessing you want to pass a ruby method as a callback to a javascript function, you could try something like this: x = { bar: method(:foo).to_proc } x.to_n But bear in mind that this might not work as intended for class methods ( the context might change on javascript)...
You could use a Promise which is a technique to manage long-term asynchronous events and avoid callback-hell. In regular Opal you would do for example: HTTP.get("url") do |response| puts "got response" end With promises, this becomes: HTTP.get("url").then do |response| puts "got response" end The difference lies in the then which...
Ok, so the problem is that the code you have is being loaded as soon as the compiled .js file loads. You need to run the code once the DOM is ready. The easy way to do this in volt is to run it on a {action}_ready method: module Main...
Something like the following should work: require 'opal' task :build do env = Sprockets::Environment.new Opal.append_path '.' Opal.use_gem 'vector2d' Opal.paths.each { |p| env.append_path(p) } File.open(ZUPFNOTER_JS, 'w+') { |out| out << env['application.js'].to_s } # … end I also suggest to use the same sprockets environment to build SCSS too as it should...
If you are using bindings in your URL, for example client '/examples/{{ category }}/{{ example }}', controller: 'examples', action: 'template' you can access those in the controller via the params collection: params._category params._example In other cases you URL should be static anyway....
Ok, so based on your sample code, you just need to make Opal.main() return a string def main # logic return str end But I think that what you really want is use opal-jquery or opal-browser, I don't have much experience with the later, so here's a simple example of...
Kernel#eval is defined in opal-parser as it needs to be able to parse Ruby into JS in the browser, so you need to require "opal-parser" first.
The following should work fine: require 'native' @Meteor = Native(`Meteor`) @Meteor.startup -> { puts 'Go' } Note that using Native you pass a lambda instead of a block...