velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter Romianowski" <megap...@gmx.de>
Subject RE: Whitespace, redux
Date Mon, 15 Apr 2002 10:55:31 GMT
Hi there,

I have to say the whitespace problem is the ONE which
I would love to see fixed (in any way). It's the (only)
"PITA" :) with it from the very beginning...
And I think that a <? ?> solution would be great.  
Although the #output("off") - thing would perhaps be more 
in the velocity-style.
And since the use of it would be optional, you would not 
break anything...

Are there plans on implementing such thing at all? I see
discussions about that come and go for a while now...

Having such a thing would make velocity REALLY the best
choice over JSP and stuff!

Peter

> -----Original Message-----
> From: Huy Do [mailto:huy@tramada.com.au]
> Sent: Monday, April 15, 2002 12:53 AM
> To: Velocity Users List
> Subject: RE: Whitespace, redux
> 
> 
> This is starting to look a bit like
> 
> <?
>   if ($option1) {
>     $a = "hello"
>   } else {
>     $a = "goodbye"
>   }
>   echo("$a")
> ?>
> 
> and replace the <? with <% (don't mind the syntax) and look what we have.
> Hope we're not going backwards now :-)
> 
> Huy
> 
> > -----Original Message-----
> > From: Joaquim Carvalho [mailto:jrc@bookmarc.pt]
> > Sent: Saturday, 13 April 2002 7:36 PM
> > To: Velocity Users List
> > Subject: Re: Whitespace, redux
> >
> >
> >
> > I have worked a long time ago in a templating language for web apps used
> > in house for over 5 years.
> >
> > We had a similar whitespace problem (control flow directives created
> > zones on the templates that produced undesired white space on the
> > output).
> >
> > The solution we found was to add two whitespace related directives,
> > "output" and "echo", that in Velocity would look something like this:
> >
> > 1. "output" switches output on and off (this applies to ALL output from
> > the template to the output stream)
> >
> > #output("off") ## from now on there is no output from the template but
> > the enclosed directives still are executed
> > #if ($option1)
> >     #set( $a = "hello")
> > #else
> >     #set($a = "goodbye")
> > #end
> > #output("on") ## restoring output
> > $a>
> >
> > 2.After a #output("off") text could be forced to the output stream by
> > using #echo:
> >
> > #output("off")
> > #if ($option1)
> >     #echo("hello")
> > #else
> >     #echo("goodbye")
> > #end
> > #output("on") ## restoring output
> >
> > 3. In macros and #parsed templates it is necessary to save and restore
> > the previous output status so that other templates can safely use code
> > in other files:
> >
> >
> > $macro ( testOption, $option1)
> >
> > #output("hold") ## Sames as "off" but the current output state is
> > remembered
> > #if ($option1)
> >     #set( $a = "hello")
> > #else
> >     #set($a = "goodbye")
> > #end
> > #output("restore") ## restoring output to previous status
> > #end
> >
> >
> >
> > this has dealt with our whitespace handling problems for good. When
> > writing sequences of directives, specially involving control structures
> > that need to be indented for readability we just backet that part of the
> > template with #output("off") #output("on") with an ocasional #echo
> > inside if something needs to go out the stream.
> >
> > This also is nice for Velocity usage just as  aruntime scripting
> > language not related to any type of outputing. We are using Velocity
> > right now in such a setting: a bibliographic application needs to do
> > some manipulation of library records according to transformation rules
> > that are defined at runtime. By adding specially designed objects to the
> > context we can use velocity as the rule language and templates just
> > specify how an object is transformed into another one. The output from
> > the template is irrelevant, so we could just as well avoida its
> > production.
> >
> > As far as velocity goes I think such a solution would be backwards
> > compatible; an implicit #output("on") is assumed for evey template (but
> > not for the parsed ones).
> >
> > I think even if a template using #output and #echo would find itself
> > being rendered by an older version of Velocity it would still work, I
> > think, because #output and #echo would just be ignored (although of
> > course the ouput would not be quite the desired one).
> >
> > This is not a request for modification, just a contribution to the
> > discussion.
> >
> > Joaquim
> >
> >
> > --
> > To unsubscribe, e-mail:
> <mailto:velocity-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
> <mailto:velocity-user-help@jakarta.apache.org>
> 
> 
> --
> To unsubscribe, e-mail:   <mailto:velocity-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:velocity-user-help@jakarta.apache.org>
> 

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