velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Townson, Chris" <C.Town...@nature.com>
Subject RE: Stripping whitespace from HTML
Date Thu, 19 May 2005 08:33:54 GMT
Fantastic - thanks to everyone for their help - I'm going to have a go with
both of these suggestions. It should really help me to get more out of
Velocity.

C 

-----Original Message-----
From: James Wilson [mailto:jwilson@nmcourt.fed.us] 
Sent: 18 May 2005 21:04
To: Velocity Users List
Subject: Re: Stripping whitespace from HTML

Townson, Chris wrote:
> Hi
> 
> I was wondering: is there any way to get Velocity to automatically 
> strip whitespace from HTML?

We created a custom writer that stripped out all extra whitespace and then
had Velocity use this new writer in it's merge procedure.

  boolean 	mergeTemplate(java.lang.String templateName, Context
context, 
java.io.Writer writer)

Attached is an example of one such writer.

James

> 
> e.g.
> 
> #stripWhitespace
> <ul>
> 	<li></li>
> 	<li></li>
> 	...
> </ul>
> #end
> 
> This functionality would be very useful for leaving html template 
> files readable whilst optimizing page size and dealing with display 
> bugs relating to Internet Explorer's rendering of CSS (e.g. links 
> displayed as block-level elements in lists).
> 
> Could it be done with a macro / has someone already written one to do
this?!
> 
> Thanks in advance for your help and suggestions,
> 
> Chris

********************************************************************************   
DISCLAIMER: This e-mail is confidential and should not be used by anyone who is
not the original intended recipient. If you have received this e-mail in error
please inform the sender and delete it from your mailbox or any other storage
mechanism. Neither Macmillan Publishers Limited nor any of its agents accept
liability for any statements made which are clearly the sender's own and not
expressly made on behalf of Macmillan Publishers Limited or one of its agents.
Please note that neither Macmillan Publishers Limited nor any of its agents
accept any responsibility for viruses that may be contained in this e-mail or
its attachments and it is your responsibility to scan the e-mail and 
attachments (if any). No contracts may be concluded on behalf of Macmillan 
Publishers Limited or its agents by means of e-mail communication. Macmillan 
Publishers Limited Registered in England and Wales with registered number 785998 
Registered Office Brunel Road, Houndmills, Basingstoke RG21 6XS   
********************************************************************************

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


Mime
View raw message