Yeah, it was Mr Fowler's article that inspired me to go the whole nine
yards. What the article does not go over is traversing an object, which gets
tricky in the dynamic landscape of Ruby. AFAIK all objects in the JRuby
runtime are wrapped in a RubyObject. The way to access the underlying object
is through the methods RubyObject#callMethod. This makes things tricky when
using Velocity, since the RubyObject passed to the VelocityEngine#evaluate
would need to go through the RubyObject#callMethod instead of directing
calling the method.

For the curious, the work I have done is at:
http://sprocket.slackworks.com/zope/swx/projects/actionview-velocity

--M

On 2/20/07, Will Glass-Husain <[EMAIL PROTECTED]> wrote:

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