Sorry, I did not read that out of your message. This would be a good feature in my opinion. Regarding the "nothing between #if and #else" problem: a line break is not enough ?
Thomas "Thoralf Rickert" <[EMAIL PROTECTED]> schrieb am 10.07.2006 11:59:43: > No, I don't want to change the templates. They will be changed > virtually during loading into the velocity renderer in a stream. > > > > -----Ursprüngliche Nachricht----- > > Von: Thomas Fischer [mailto:[EMAIL PROTECTED] > > Gesendet: Montag, 10. Juli 2006 10:17 > > An: Apache Torque Developers List > > Betreff: Re: Velocity Templates > > > > > > Hi, > > > > The spaces in front of the velocity commands exist because it > > makes the templates themselves readable. I'd put more > > emphasis on keeping the templates readable than the generated > > code, so I'd rather leave the spaces where they are. > > > > Thomas > > > > "Thoralf Rickert" <[EMAIL PROTECTED]> schrieb am 10.07.2006 > > 09:43:18: > > > > > Hi! > > > > > > I think there is an open discussion thread (in 2005) about the > > > generated code style in the Base* classes but I can't find it. The > > > "problem" is that the generated code looks a little bit > > ugly because > > > of too many spaces. This is a velocity problem, because of leading > > > spaces in front of velocity commands like #if and #end. > > > > > > We've the same problem in one of our projects where we use velocity > > > templates to render XHTML pages. There I made a small patch in our > > > VelocityTemplateLoader to generate better code. > > > > > > Here is an example of a template: > > > public void helloWorld() > > > { > > > #if($useLog) > > > log.debug("Hello World called"); > > > #else > > > System.out.println("Hello World called"); > > > #end > > > } > > > > > > These leading spaces makes the code "unattractive" and sometimes > > > unreadable. The patch is to remove any leading spaces in > > front of any > > > velocity command. It's a line-by-line replacement regex > > with "^\s#" to > > > "#". The result that is send to the renderer looks like this. > > > > > > public void helloWorld() > > > { > > > #if($useLog) > > > log.debug("Hello World called"); > > > #else > > > System.out.println("Hello World called"); > > > #end > > > } > > > > > > > > > The solution is simple but doesn't fix every problem. Of > > course this > > > could generate other problems. For example the following > > code compiles > > > well without the patch. > > > > > > But with the patch it creates a velocity compile error, because of > > > missing output between #if and #else > > > > > > public void helloWorld() > > > { > > > #if($useLog) > > > #else > > > System.out.println("Hello World called"); > > > #end > > > } > > > > > > If you're interested in such a patch I would make it for the > > > torque-generator. > > > > > > bye > > > Thoralf > > > > > > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
