freemarker.template.utility
Class CompressWhitespace

java.lang.Object
  |
  +--freemarker.template.utility.CompressWhitespace
All Implemented Interfaces:
TemplateModel, TemplateTransformModel

public class CompressWhitespace
extends java.lang.Object
implements TemplateTransformModel

A transform model that compresses each occurrence of consecutive whitespace down to a single space character. Leading and trailing whitespace is also removed.

Usage:
From java:

 TemplateModelRoot root = new SimpleHash();

 root.put( "compressWhitespace", new freemarker.template.utility.CompressWhitespace() );

 ...
 

From your FreeMarker template:


 The following is compressed:
 <transform compressWhitespace>
   <p>This paragraph has all whitespace reduced to a single
   space character.</p>
 </transform>

 ...
 

Version:
$Id: CompressWhitespace.java,v 1.7 2002/03/09 20:57:04 revusky Exp $
See Also:
LegacyCompress

Constructor Summary
CompressWhitespace()
          Creates new CompressWhitespace
 
Method Summary
 boolean isEmpty()
           
 void transform(java.io.Reader source, java.io.Writer output)
          Compresses whitespace within the marked portion of a FreeMarker template.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompressWhitespace

public CompressWhitespace()
Creates new CompressWhitespace
Method Detail

transform

public void transform(java.io.Reader source,
                      java.io.Writer output)
               throws TemplateModelException,
                      java.io.IOException
Compresses whitespace within the marked portion of a FreeMarker template.
Specified by:
transform in interface TemplateTransformModel
Parameters:
source - the input to be transformed
output - the destination of the transformation

isEmpty

public boolean isEmpty()
                throws TemplateModelException
Specified by:
isEmpty in interface TemplateModel
Returns:
true if this object is empty.