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
2
votes
1 answer

require 'opal-jquery' gives error: A file required wasn't found

Opal looks amazing!!! I'm getting the same "A file required wasn't found" error when I try to require 'opal-jquery' on two different Windows 7 and Windows 10 systems: C:\opaltest>node --version v10.15.3 C:\opaltest>ruby -v ruby 2.5.5p157…
2
votes
1 answer

How to convert ruby - Rspec to js test - opal gem

In my Ruby on Rails app I use opal gem for converting the ruby code to JS. How can I convert also the Rspec tests to JS test - opal. And how to run those JS/opal tests? Thank
Shir
  • 253
  • 1
  • 6
  • 18
2
votes
1 answer

How can I use require_relative when compiling with Opal and subsequently running in Node?

I am totally new to Opal. I am just testing out how to use it by writing simple Ruby code in a local file, compiling it using opal -c test.rb > test.js, and then executing the resultant js file using node test.js. This is working fine when all of…
Huliax
  • 1,489
  • 3
  • 15
  • 27
2
votes
1 answer

How to transpile Slim with Opal?

Slim is a template language which I'd like to use in a client-side web app(which should be capable of working offline). I wonder if I can use Opal to transpile it. If so, then how to do it? And if it is impossible at the moment, could you please…
user5455
  • 53
  • 4
2
votes
2 answers

Production usage of compiling Ruby Red to javascript

There has been a lot of discussion over this ability (such as in this SO question, or this github thread) to compile ruby to Javascript. The original version of Red is quite old, but Julius Eckert seems to have picked it up and made it far more…
2
votes
3 answers

Linking Ruby with HTML Code

I am aware that you can implement Javascript code to an HTML documents, by inserting the code between the tags.. is there a similar way to do this with Ruby?
2
votes
1 answer

Integrate opalrb with sprockets on sinatra

I'm wanting to integrate Opal into my next project and decided to just move onto sprockets from sinatra-asset-pack, however I can't find anything on how to integrate opal into sprockets rather than just setting up sprockets and opal separately. How…
Thermatix
  • 2,757
  • 21
  • 51
2
votes
1 answer

How to make pages with a "template" controller and view in VoltRb

I'm having a problem in Volt where I need a bunch of pages with a "template" controller and view. Let me explain this in a little more detail: Say, for example, I have a site about books. I have a page at http://localhost:3000/books. It serves as an…
GDP2
  • 1,948
  • 2
  • 22
  • 38
2
votes
1 answer

How do I do a jQuery toggleClass in Volt?

I'm playing around with Volt and currently trying to do a simple toggleClass for a sidebar in my Volt app (with no luck). Here is a code sample. app/main/views/main.html <:Title> {{ view main_path, "title", {controller_group: 'main'}…
luc
  • 43
  • 6
2
votes
1 answer

How can I utilize Sourcemaps when debugging Opalrb

Opal is generating source maps. I can enable JavaScript source maps in chrome, set breakpoints it even stops in debugger. But it is still not of much practical use. I cannot investigate local variables. Even if I try to evaluate the same in…
Bernhard
  • 686
  • 8
  • 20
2
votes
1 answer

How can I generate a sample Rails app with Opal?

I'm following the guide at http://opalrb.org/docs/rails/ . The first step goes fine: rails new MyHappyApp --javascript=opal But when I try to actually generate a scaffold... rails g scaffold Persion name…
HappyCoder86
  • 2,267
  • 3
  • 25
  • 40
1
vote
1 answer

Compile an opalized Ruby gem to Node package

It's not clear to me from the docs and guides whether the following is feasible with Opal: I've written a builder gem which implements an API to build an object tree which is then written to XML (or AIXM to be exact, an aeronautical format). There…
svoop
  • 3,318
  • 1
  • 23
  • 41
1
vote
1 answer

Accessing DOM using Opal Ruby : how to install gems properly?

I'd like to test some simple SVG animations with the help of Opal Ruby, that stands as a Ruby to Javascript transpiler. However my first steps in using Opal are awkward. I can't access the the dom (document object model) at all. It seems that my…
JCLL
  • 5,379
  • 5
  • 44
  • 64
1
vote
2 answers

Can I make a functional component in Hyperstack?

All of the documentation refers to creating components using classes. Can I make a functional component in order to leverage react hooks, and if so, how? To clarify, I can only find documentation for creation a class based component like class…
Cereal
  • 3,699
  • 2
  • 23
  • 36
1
vote
1 answer

Setting active state on a Nav item depending on the Route using ReactBootstrap

What is the best way of ensuring the correct Nav Item is selected using React Bootstrap and Hyperstack Router? I know I can the Link method, but I want to use the specific Bootstrap Nav item instead. Is there a good example of this anyone can share?
BarrieH
  • 373
  • 3
  • 11