velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "kelly.muniz" <kmu...@cisco.com>
Subject RE: reference to an array element
Date Fri, 18 Apr 2003 17:44:08 GMT

Christoph, after upgrading to the latest Velocity engine/libraries, the
following code now works fine:

#set( $nav = [ "title", "url", true ] )
$nav
$nav.set( 0, "new title" )
$nav

The output is:
[title, url, true]
title
[new title, url, true]

I appreciated your help, thanks.

> -----Original Message-----
> From: Christoph.Reck@dlr.de [mailto:Christoph.Reck@dlr.de]
> Sent: Thursday, April 17, 2003 2:23 AM
> To: Velocity Users List
> Subject: Re: reference to an array element
>
>
> embedded answer...
>
> kelly.muniz wrote:
> > Christoph,
> >
> > I tried your suggestion but it does seem to work.
> >
> > 1. As you said, without the extra "#**#", I get a parsing error.
>
> Well, the parser bug still exists then. Someone may claim it is a feature
> to disallow empty #if statements... *but* there seems no other way of
> handling a transparent #call macro other than using an #if:
> #macro( call $foo )##
> #if( $foo )## the if statement just invisibly wraps the evaluation
> #end##
> #end
>
> ## the following does not work since due to marco internals the ! breaks
> ## the macro reference. Without the !, you get an error in the log if it
> ## evaluates to null.
> #macro( call $foo )##
> #set( $dummy = "$!foo" )
> #end
>
> Excuse me for the wordines, but since others (core developers) may be also
> reading this, I want to give them some hints of things that are
> problematic.
>
> > 2. After doing "#if( $nav.set(0, "new title") )#**##end", if I
> print $nav,
> > it still has the old value for element 0.
>
> Look at the logs.
>
> If you did not find anything there, try your template without the
> enclosing #if - it may be hinding some exception or log message.
>    $nav.set(0, "new title")## emits the old title to template output
>    $nav
> According to the Collection.set() method API you should see the old
> title in the template output and the new value set within $nav. If
> this is not what you observe, there should be a good hint in the
> log file now!
>
> >
> > Thanks.
>
> --
> :) Christoph Reck
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Mime
View raw message