From: Michael Neumann Date: 2007-01-14T20:11:05+09:00 Subject: Re: [ANN] RubyJS - Convert Ruby to Javascript Michael Neumann wrote: > Am Sonntag, 14. Januar 2007 09:05 schrieb Une B�vue: >> Michael Neumann wrote: >> > With RubyJS you can transform a subset of Ruby into Javascript code. >> >> yes but how to interact with the browser window, for example, say i have >> a : >> >>
 in the html document and i want to redefine ruby
>> puts like this :
>>
>> def puts(str)
>>   document.getElementById('STDOUT')['inneHTML'] += str + "\n"
>> end
>>
>> if i do that into your HelloWorld class i get errors :
> 
> Well, does it work in Ruby? NO! So it doesn't work in RubyJS as well :)
> It's a bit more advanced than converting "document" from Ruby plainly
> into "document" in Javascript.
> 
> If you want to insert Javascript code directly into your Ruby code, use
> backticks:
> 
>   def puts(str)
>     `document.getElemementById('STDOUT')['innerHTML'] += str + "\n"`
>   end

Sorry! Actually it should be:

   def puts(str)
     `document.getElemementById('STDOUT')['innerHTML'] += # + "\n"`
   end

Notice the #, which correctly converts variable names.

Regards,

  Michael