Charles Oliver Nutter
12/24/2006 10:58:00 AM
Naked Sushi wrote:
> This probably has a simple answer, but I don't know it.
>
> Let's say I have a ruby script called hello.rb
>
> #!/usr/bin/ruby
> def greeting ()
> return "Hello world!"
> end
>
> I want to call that script from within an HTML document. How would I do
> so? Within the HTML document, would I just treat it the same way I call
> external javascript:
>
> <script src="path/to/hello.rb" type="text/ruby"></script>
>
> How would I make the function call?
>
I have been interested in making this happen using an applet in JRuby.
By wiring in a call to the applet that loads the ruby file, it should be
possible to get the applet to run the script and return some result. The
interplay between the page and the applet would have to go over
"liveconnect" or something similar to work.
The applet part is basically taken care of, and has been used to create
an IRB GUI that runs in a browser. The LiveConnect/javascript stuff I
have only done very cursory research into, but it seems that it should
be possible.
If you're interested in this angle further, you can contact me or join
the jruby lists...or just talk about it here, though I'm not as good
about checking ruby-talk lately :)
--
Charles Oliver Nutter, JRuby Core Developer
Blogging on Ruby and Java @ headius.blogspot.com
Help spec out Ruby today! @ www.headius.com/rubyspec
headius@headius.com -- charles.nutter@sun.com