velocity-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 11924] - Add Support for Static Utility Classes
Date Sun, 25 Aug 2002 10:21:11 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11924>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11924

Add Support for Static Utility Classes





------- Additional Comments From baliuka@mwm.lt  2002-08-25 10:21 -------
"#with" macro ( idea from Pascal )
This is not static method specific and can be used
 for bean properties too :

 #with math, formatUtils, bean

  $format( $sin($x) )
  $format( $cos($x/2) )

 #end

becomes this :

  $formatUtils.format( $math.sin( $bean.x ) )
  $formatUtils.format( $math.cos( $bean.x/2 ) )


"#with .. as" form:

 #with math, formatUtils, bean as t

  $t.format( $t.sin($t.x) )
  $t.format( $t.cos($t.x/2) )

 #end

I am not sure about "use/uses" macro it loads class from template and it is not 
very secure and can be problems with ClassLoaders:

 #use java.lang.Math as math

Some code generation tools provide Velocity templates and it is possible to 
replace them with custom templates, but API working with context is private.
I know "properties" can help to add tools, but I like this way too.

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


Mime
View raw message