You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by "EXTERN Shakirov Timur (Firma ISS; GS-EC/EMT2)" <Ti...@de.bosch.com> on 2004/08/12 16:48:44 UTC

Add custom functions to context?

Hello,

Is it possible to call custom function in Velocity macro without using object name?

I.e., instead of using:

$myClass.myFunction("my String")

I would like to use:

myFunction("my String")

WbW,
Tim
============================================================
Robert Bosch GmbH
(iss GmbH)
Dept. GS-EC/EMT2
Robert Bosch Str. 2
D-71701 Schwieberdingen
Germany 
Phone: +49 (711) 811-49483
E-Mail: Timur.Shakirov@de.Bosch.com 



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


Re: Add custom functions to context?

Posted by Simon Christian <si...@stoutstick.com>.
Well you might 'wrap' your custom function by defining a macro e.g.

#macro( myFunction $myString )
$myClass.myFunction( $myString )
#end

then to call it, simply:

#myFunction( $myString )

Obviously the object $myClass needs to be available in the context.

- simon


EXTERN Shakirov Timur (Firma ISS; GS-EC/EMT2) wrote:
> Hello,
> 
> Is it possible to call custom function in Velocity macro without using object name?
> 
> I.e., instead of using:
> 
> $myClass.myFunction("my String")
> 
> I would like to use:
> 
> myFunction("my String")
> 
> WbW,
> Tim
> ============================================================
> Robert Bosch GmbH
> (iss GmbH)
> Dept. GS-EC/EMT2
> Robert Bosch Str. 2
> D-71701 Schwieberdingen
> Germany 
> Phone: +49 (711) 811-49483
> E-Mail: Timur.Shakirov@de.Bosch.com 
> 
> 
> 
> ---------------------------------------------------------------------
> 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