You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Peter Lynch <pe...@yahoo.com> on 2001/07/04 03:24:13 UTC

More Gobbling whitespace...

I originally posted this to turbine-user by mistake.
They provided good feedback, but I thought I should
repost to my original intended list for your comments.
Thanks,
-----------------------------------------

Greetings,

To save response size of content delivered
over the web, I am looking for a way to return
templates written like this :

-----8<----------
<html>
<head>



</head>

<body>
    This is tabbed text
  

    <br>
        Here is the next line that starts with
spaces.</body>


    </html>
----8<-----------------

To output to the browser like:

----8<----------------
<html>
<head>
</head>
<body>
This is tabbed text
<br>
Here is the next line that starts with spaces.
</body>
</html>
----8<-------------------The output would be much
cleaner and less readable
using view source and smaller in size to download.
We had an inhouse template parser that had this
functionality.
Is there a way that output generated by velocity can
gobble:
1) leading whitespace, and tabs
2) trim all whitespace and tabs at the end of lines
3) maintain new line characters
4) remove empty lines

all without the various hacks I have seen like using
comment directives at the beginning of lines.
It would be nice to have this be turned on and off via
a property so that developers could always get the
formatted source to help debugging. I realize this may
useful for only
web based templates, but hey it would be very cool
tohave.

Maybe velocity can do this already?

-Peter


__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

Re: More Gobbling whitespace...

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
Peter Lynch wrote:
> 
> I originally posted this to turbine-user by mistake.
> They provided good feedback, but I thought I should
> repost to my original intended list for your comments.
> Thanks,
> -----------------------------------------
> 
> Greetings,
> 
> To save response size of content delivered
> over the web, I am looking for a way to return
> templates written like this :
> 
> -----8<----------
> <html>
> <head>
> 
> </head>
> 
> <body>
>     This is tabbed text
> 
> 
>     <br>
>         Here is the next line that starts with
> spaces.</body>
> 
>     </html>
> ----8<-----------------
> 
> To output to the browser like:
> 
> ----8<----------------
> <html>
> <head>
> </head>
> <body>
> This is tabbed text
> <br>
> Here is the next line that starts with spaces.
> </body>
> </html>
> ----8<-------------------The output would be much
> cleaner and less readable
> using view source and smaller in size to download.
> We had an inhouse template parser that had this
> functionality.
> Is there a way that output generated by velocity can
> gobble:
> 1) leading whitespace, and tabs
> 2) trim all whitespace and tabs at the end of lines
> 3) maintain new line characters
> 4) remove empty lines
> 
> all without the various hacks I have seen like using
> comment directives at the beginning of lines.
> It would be nice to have this be turned on and off via
> a property so that developers could always get the
> formatted source to help debugging. I realize this may
> useful for only
> web based templates, but hey it would be very cool
> tohave.
> 
> Maybe velocity can do this already?

No we have talked about it, but I think we should try to keep things as
general as possible.  You could always post-process the generated output
stream.  That would be a nice tool to have around.

geir

-- 
Geir Magnusson Jr.                           geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
You have a genius for suggesting things I've come a cropper with!