Something I have wished for in the past are more sophisticated programming structures in the Velocity code of templates. According to the “Apache Commons JEXL Sytnax Reference” guide, supplied to us by Percussion, JEXL should be able to do while loops. But this has not been implemented, as far as I can tell, in Velocity templates, only foreach loops. Also, we have a lot of templates that have long and highly nested #if… #else… #end statements. These could be much more elegantly implemented with Select Case, if such a thing existed.
That seems to be a limitation of Velocity’s IteratorTool. In this article, the author explains why he thinks that’s a good limitation, but also, that “it is possible to modify Velocity to add a #while directive to the template language.”
If you are more of a developer type and feel that velocity and jexl do not have the expression power you need you can always write a custom jexl expression using Java. In fact I have written unofficial unsupported custom jexl expression that will call a groovy script (its like Python http://groovy.codehaus.org/ ) to do the heavy lifting on complicated templates. Then I can just update my groovy script. No need to recompile :).
Cool. What are the steps necessary for this (making calls to groovy in page templates via a jexl)?
It would be great if this could be incorporated into a installer script. If this was part of the core product I think it could be valuable in the product marketing / strategy since it would allow for easy customizations.
If you are more of a developer type and feel that velocity and jexl do not have the expression power you need you can always write a custom jexl expression using Java. In fact I have written unofficial unsupported custom jexl expression that will call a groovy script (its like Python http://groovy.codehaus.org/ ) to do the heavy lifting on complicated templates. Then I can just update my groovy script. No need to recompile :).[/QUOTE]