Questions tagged [opalrb]

Opal is a Ruby to JavaScript source-to-source compiler. It comes packed with the Ruby corelib you know and love. It is both fast as a runtime and small in its footprint.

Opal is a Ruby to JavaScript compiler. It is source-to-source, making it fast as a runtime. Opal includes a compiler (which can be run in any browser), a corelib and runtime implementation. The corelib/runtime is also very small.

Opal is hosted on github, discussed on Gitter, has a Freenode IRC channel at #opal and is on twitter @opalrb.

More documentation can be found in the docs.

92 questions
0
votes
1 answer

How to dynamically modify CSS using Python?

I'm creating a Flask-based web app. I need to modify the CSS of an element dynamically. To be more specific, I have a file that I want to read from Python. Based on what I read from the file, I want to modify the CSS of an element. Just to give you…
Maruth goyal
  • 71
  • 2
  • 6
0
votes
2 answers

Has Anyone Used Chronic or ChronicDuration in VoltRB?

I've put the chronic and chronic_duration gems in my Gemfile, and everything works fine in volt console. However, if I try anything on the client side, I get a name error. I tried requiring them in a client-side initializer, but that didn't…
Steve Ross
  • 4,134
  • 1
  • 28
  • 40
0
votes
1 answer

How and where does the `require_table` variable get stored? (OpalRb)

So, I was recently reading through the require system of OpalRb, and came across the interesting require_table variable. Reading through the methods there, it's clear that require_table is used to see whether a file has already been loaded or not,…
GDP2
  • 1,948
  • 2
  • 22
  • 38
0
votes
1 answer

Opal file called from client via getsctipt (or xhr'ed and evaled) can't be evaled and used

I want to xhr some opal script, and use ruby code defined there. I tried to get it with $.getScript. But no success for me. $.ajax({ url: 'assets/foo.js.rb', success: function(data){ #{ClassInFooJs.new} }, dataType:…
Sheppard
  • 157
  • 1
  • 10
0
votes
1 answer

Opal.rb bridged class inner mechanics

I want to know how exactly bridging to native classes does internally work. (can't find any documentation on that). function NativeClass() { this.foo = "bar"; } class MyClass
Sheppard
  • 157
  • 1
  • 10
0
votes
1 answer

Error while trying to convert ruby code to javascript

I'm trying to use Opal to convert ruby code to javascript. At first, it looked pretty promising, but it just doesn't work with my class. I get the below error which does not make sense to me: SyntaxError: An error occurred while compiling:…
Horse Voice
  • 8,138
  • 15
  • 69
  • 120
0
votes
2 answers

Embedding serverside Ruby to opal files in rails

Is it possible to embed serverside ruby to Opal .js.rb files? In other words I need to access for example User.find(1) in some opal file in Rails, like one would do with .erb.
ClassyPimp
  • 715
  • 7
  • 20
0
votes
0 answers

PhantomJS load issues in fresh Volt app

I tried to run BROWSER=phantom rspec spec on a newly created Volt App and hit the following error: WARNING: LoadError: cannot load such file -- volt/views/notices/index # ... continues for some time ... This was a pretty default spec: require…
Rick
  • 8,366
  • 8
  • 47
  • 76
0
votes
3 answers

Fire an action when a link gets clicked to a page that has the same action (VoltRb)

At http://localhost:3000/books, I have an index page where I have a list of books. When you click on one of the links, the action to which it is bound, book, gets fired: However, when you click on one of the links from one of the book pages, the…
GDP2
  • 1,948
  • 2
  • 22
  • 38
0
votes
1 answer

Selenium timeout in Volt 0.9.5pre4

I tried to run BROWSER=firefox rspec spec on a freshly created Volt App and got this error: Selenium::WebDriver::Error::WebDriverError: unable to obtain stable firefox connection in 60 seconds (127.0.0.1:7055) The app hangs and raises that error…
Rick
  • 8,366
  • 8
  • 47
  • 76
0
votes
1 answer

opal-jquery ajax request sending malformed json string

I'm using opal-jquery to send an ajax request to my backend, but the json payload is malformed when I try to access it on the backend. When I do puts @params.to_s on my back end, it gets displays as: {"{\"username\":\"some_user\",…
Thermatix
  • 2,757
  • 21
  • 51
0
votes
1 answer

Having trouble with opal and trying to render out a simple react.rb template

I'm trying to use the react.rb gem with opal however I'm having trouble with it. The following is a simple hello world component, nothing complex. class Hello_World include React::Component define_state(:message) { "Hello World!" } def…
Thermatix
  • 2,757
  • 21
  • 51
0
votes
1 answer

Where to put frontend `require` files in a Volt project

I'm writing an app that requires me to define a Ruby class outside of the controller, and then instantiate it within a controller. I put it in lib/my_file.rb and also initializers/client/my_file.rb and got the same result: Sprockets::FileNotFound…
Rick
  • 8,366
  • 8
  • 47
  • 76
0
votes
1 answer

Seed Random in Opal

Is there a way to seed a random number generator in Opal? srand doesn't seem to do anything, and using the Random class directly errors out with NameError: uninitialized constant Object::Random.
neurodynamic
  • 4,294
  • 3
  • 28
  • 39