Re: Trying to do something simple... and failing

16 views
Skip to first unread message

Elia Schito

unread,
Oct 23, 2016, 5:08:31 PM10/23/16
to opa...@googlegroups.com

On Thu, Oct 13, 2016 at 2:44 PM, <jhu...@gmail.com> wrote:
I've just found out about opal, but can't seem to get my head around how to deal with my usecase:

I've written a DSL in Ruby, and would like to allow users to put a small program (using the DSL) into a textbox, hit "run", and see some output. This, as far as I can see, is equivalent to me defining some methods in ruby, and allowing users to call these methods. What this in turn means is that I need to precompile my methods (e.g., via opal.compile), and then use something like opal-box to allow users to run their code which calls my methods.

While I can get some javascript out of my ruby code using the Opal parser, I can't work out how to allow this javascript to be called from ruby inside opal-box.

A simple example of what I want to do:

I have a file "hello.rb"
def hello()
  return "hi"
end

I'd like the user to be able to write
puts hello
within a opal-box in their browser, and get "hi" printed as output.

Does anyone have any suggestions how to do so?

Thanks.

--
You received this message because you are subscribed to the Google Groups "opalrb" group.
To unsubscribe from this group and stop receiving emails from it, send an email to opalrb+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages