velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Denis <j...@respublica.fr>
Subject Re: Variable method name in a macro?
Date Tue, 08 Oct 2002 11:23:34 GMT
Hi Chris,

On Tuesday, October 8, 2002, at 08:44  am, Chris Miller wrote:

> That's not what I'm after though. What I really want is a way to 
> pass this
> exact string (excluding the quotes) through to my tool:
>
> "$book.title"
>
> The catch of course is that the String "title" needs to be evaluated by
> Velocity first, since I am retrieving the value from elsewhere in the
> context. So, similar to what Aapo is after, I only want to evaluate the
> second half of the expression (ie the method name), and then pass 
> the whole
> string through to my eval() method which will then effectively 
> evaluate the
> expression a second time.
>
> ie:
>
> $book.$propertyName  ## Only evaluate the $propertyName
> $book.title          ## Result of the first evaluation
> The Lord of the Rings    ## Result of the second evaluation (ie, 
> the result
> of the call to $tool.eval("$book.title"))

Does this do what you want...

#set ($pre = '$book.')
#set ($bookeval = "$pre$propertyName")
$took.eval($bookeval)

-- Denis.

>
> Thanks for your patience so far :-)
> Chris
>


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


Mime
View raw message