I haven't played with this myself, but have you seen this article?

http://www.martinfowler.com/bliki/JRubyVelocity.html

WILL

On 2/20/07, Michael <[EMAIL PROTECTED]> wrote:
Hello,

I have been using Velocity for years now and find it the best templating
language around. This has lead me to try and spread the joy by attempting to
swap out RHTML for Velocity in JRuby on Rails.

I have a few simple Ruby test scripts that parse a templates Velocity.
Things get messy when Velocity needs to traverse an object graph. When used
in Rails, the VelocityContext can have a mix of Java objects and RubyObject
(these are the problematic ones).  The RubyObject is a wrapper for a Ruby
object from the JRuby runtime. The RubyObjects do not have static typed
methods, but everything must go through the method 'callMethod'.

For example, to use velocity notation on the Java object 'sample' to get the
method 'test':
   $sample.test

would be on a RubyObject 'sample' to get the method 'test':
   $sample.callMethod( $sample.getRuntime(), "test" )

Things get sticker for passing arguments to a method in RubyObject, all
arguments must implement IRubyObject. I will just skip over this for now.

Here is the crux of my question,  is it possible to extend Velocity to add
support for handling RubyObjects? Ideally Velocity would be able to
determine whether an object is an implementation of RubyObject, or not, and
handle appropriately, i.e $jrubyObject.testMethod could be call directly
instead of the callMethod for a RubyObject.


thanks,
Michael
[EMAIL PROTECTED]



--
Forio Business Simulations

Will Glass-Husain
[EMAIL PROTECTED]
www.forio.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to