velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Geir Magnusson Jr." <ge...@optonline.net>
Subject Re: Quick Question.
Date Mon, 09 Sep 2002 17:07:05 GMT
(expect to be able to join the party tomorrow...  My response is probably
predictable...)

On 9/9/02 1:00 PM, "Barbara Baughman" <baughman@utdallas.edu> wrote:

> My program line might look like:
> 
>        #foreach ($field in $cols)#if ($velocityCount>1), $field.name#end#end
> 
> The template defines an output file that will be a java program, and I
> want the program indentation to be consistent and readable in the output
> file.  Just as you want your HTML output to be pretty, I want my Java to
> be pretty.
> 
> The templating may be ugly, but the whitespace handling is at least
> predictable to me.  This was meant to be a templating language, not a
> programming language with conventions about pretty indenting to make it
> more readable, where beginning and ending whitespace are irrelevant.

+1

> 
> Instead of making a lot of rules about how to change Velocity whitespace
> handling, I suggest preparing some tools on the side that make it easier
> to troubleshoot Velocity templates.
> 
> I suggest having a simple Java program that you feed your template into,
> and it outputs each line of the template and the nesting level of each
> line, since indentation really helps you keep track of nesting for
> troubleshooting.
> 
> Line of code                                 LEVEL
> ------------                                 -----
> This is an example                           0
> #foreach ($field in $cols)                   1
> #if ($velocityCount>1                        2
> something$field                            2
> #end                                         1
> #end                                         0
> Just a thought                               0
> 
> The output is very helpful in identifying missing or misplaced #end
> statements, and is more reliable than the programmer remembering to
> indent.
> 
> Or perhaps a tool that reformats a template to make the directives stand
> out more and automatically indents the #foreach and #if directives.  Or
> conversely, a tool that takes the template with the indentation you like
> and translates it without leading spaces in front of the directive for
> use in production, providing pretty HTML output.
> 
> One of the beauties of Velocity is its simplicity.  I would like to keep
> it that way and work around the whitespace indentation if it bothers you.
> Personally, I don't find whitespace handling to be a problem.  Just my
> humble opinion.

+1

:)

-- 
Geir Magnusson Jr. 
Research & Development, Adeptra Inc.
geirm@adeptra.com
+1-203-247-1713



--
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