Home » freemarker-2.3.13 » freemarker.template.utility » [javadoc | source]
freemarker.template.utility
public class: StandardCompress [javadoc | source]
java.lang.Object
   freemarker.template.utility.StandardCompress

All Implemented Interfaces:
    TemplateTransformModel

A filter that compresses each sequence of consecutive whitespace to a single line break (if the sequence contains a line break) or a single space. In addition, leading and trailing whitespace is completely removed.

Specify the transform parameter single_line = true to always compress to a single space instead of a line break.

The default buffer size can be overridden by specifying a buffer_size transform parameter (in bytes).

Note: The compress tag is implemented using this filter

Usage:
From java:

SimpleHash root = new SimpleHash();

root.put( "standardCompress", new freemarker.template.utility.StandardCompress() );

...

From your FreeMarker template:

<transform standardCompress>
<p>This paragraph will have
extraneous

whitespace removed.</p>
</transform>

Output:

<p>This paragraph will have
extraneous
whitespace removed.</p>
Field Summary
public static final  StandardCompress INSTANCE     
Constructor:
 public StandardCompress() 
 public StandardCompress(int defaultBufferSize) 
Method from freemarker.template.utility.StandardCompress Summary:
getWriter
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from freemarker.template.utility.StandardCompress Detail:
 public Writer getWriter(Writer out,
    Map args) throws TemplateModelException