You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by "Will Glass-Husain (JIRA)" <ji...@apache.org> on 2005/09/18 23:48:54 UTC

[jira] Updated: (VELOCITY-253) Enhance whitespace gobbling

     [ http://issues.apache.org/jira/browse/VELOCITY-253?page=all ]

Will Glass-Husain updated VELOCITY-253:
---------------------------------------

    Bugzilla Id:   (was: 27413)
    Fix Version: 2.0
    Description: 
I expect that when adding velocity markup to an existing text file
to not affect the spacing in the output. This includes indented #foreach
directives and inner indented #if/#set/#macro directives.

So the rule I proposed was to allow adding velocity markup, one per line,
and still have the same output - e.g. add an #if statement around
existing text to conditionally mask it out. Or add an #foreach around
a table row and be able to repeat the body with dynamic data, etc.

As sonn as a directive is placed wihtin other text in the same line, 
any whitespace around it should remain untouched.

If a line is looks like this:
  DirectiveLine ::= LineEnd TabsAndSpaces? Directive TabsAndSpaces? LineEnd
  TabsAndSpaces ::= (#x20 | #x09)+
  LineEnd       ::= StartOfStream | ((#x0D #x0A) | #x0D | #x0A) | EndOfStream
then the first "TabsAndSpaces?" and the closing "TabsAndSpaces? LineEnd"
should be gobbled. (Note that it supports multiline directives, that is
why "DirectiveLine" is not simply "Line".) If you whant the first
"LineEnd" to be gobbled prepend a ## before it (makes the EOL part of 
the previous line!).


This has been an isse since velocity birth and discussed in many 
user and developer threads. Some users agree with my proposals,
some say that velocity sould not touch any whitespaces and a 
code formatter should be run after the template rendering.


The proposal is not 100% BC, but a switch could allow the classic 
style (by default), or to pass all whitespaces.

A new directive could be created to control the gobbling for 
the enclosed parts within a template.

  was:
I expect that when adding velocity markup to an existing text file
to not affect the spacing in the output. This includes indented #foreach
directives and inner indented #if/#set/#macro directives.

So the rule I proposed was to allow adding velocity markup, one per line,
and still have the same output - e.g. add an #if statement around
existing text to conditionally mask it out. Or add an #foreach around
a table row and be able to repeat the body with dynamic data, etc.

As sonn as a directive is placed wihtin other text in the same line, 
any whitespace around it should remain untouched.

If a line is looks like this:
  DirectiveLine ::= LineEnd TabsAndSpaces? Directive TabsAndSpaces? LineEnd
  TabsAndSpaces ::= (#x20 | #x09)+
  LineEnd       ::= StartOfStream | ((#x0D #x0A) | #x0D | #x0A) | EndOfStream
then the first "TabsAndSpaces?" and the closing "TabsAndSpaces? LineEnd"
should be gobbled. (Note that it supports multiline directives, that is
why "DirectiveLine" is not simply "Line".) If you whant the first
"LineEnd" to be gobbled prepend a ## before it (makes the EOL part of 
the previous line!).


This has been an isse since velocity birth and discussed in many 
user and developer threads. Some users agree with my proposals,
some say that velocity sould not touch any whitespaces and a 
code formatter should be run after the template rendering.


The proposal is not 100% BC, but a switch could allow the classic 
style (by default), or to pass all whitespaces.

A new directive could be created to control the gobbling for 
the enclosed parts within a template.

    Environment: 
Operating System: other
Platform: Other

  was:
Operating System: other
Platform: Other

      Assign To:     (was: Velocity-Dev List)

FYI.  There's an extensive discussion of this in the WIKI.  Scheduling for 2.0.  

Be great if someone wanted to take a crack at a patch at some point.  The tricky thing of course is that a lot of this behavior is specified with tokens in Parser.jjt.   Thus a "configuration switch" is pretty tough.

> Enhance whitespace gobbling
> ---------------------------
>
>          Key: VELOCITY-253
>          URL: http://issues.apache.org/jira/browse/VELOCITY-253
>      Project: Velocity
>         Type: Bug
>   Components: Source
>     Versions: 1.0-Release
>  Environment: Operating System: other
> Platform: Other
>     Reporter: Christoph
>      Fix For: 2.0

>
> I expect that when adding velocity markup to an existing text file
> to not affect the spacing in the output. This includes indented #foreach
> directives and inner indented #if/#set/#macro directives.
> So the rule I proposed was to allow adding velocity markup, one per line,
> and still have the same output - e.g. add an #if statement around
> existing text to conditionally mask it out. Or add an #foreach around
> a table row and be able to repeat the body with dynamic data, etc.
> As sonn as a directive is placed wihtin other text in the same line, 
> any whitespace around it should remain untouched.
> If a line is looks like this:
>   DirectiveLine ::= LineEnd TabsAndSpaces? Directive TabsAndSpaces? LineEnd
>   TabsAndSpaces ::= (#x20 | #x09)+
>   LineEnd       ::= StartOfStream | ((#x0D #x0A) | #x0D | #x0A) | EndOfStream
> then the first "TabsAndSpaces?" and the closing "TabsAndSpaces? LineEnd"
> should be gobbled. (Note that it supports multiline directives, that is
> why "DirectiveLine" is not simply "Line".) If you whant the first
> "LineEnd" to be gobbled prepend a ## before it (makes the EOL part of 
> the previous line!).
> This has been an isse since velocity birth and discussed in many 
> user and developer threads. Some users agree with my proposals,
> some say that velocity sould not touch any whitespaces and a 
> code formatter should be run after the template rendering.
> The proposal is not 100% BC, but a switch could allow the classic 
> style (by default), or to pass all whitespaces.
> A new directive could be created to control the gobbling for 
> the enclosed parts within a template.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


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