|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object freemarker.ext.misc.CompressLines
public final class CompressLines
A transform model that strips trailing whitespace from every line, and reduces consecutive blank lines to a single blank line. This transformation is useful as a global filter.
Note: this is not a content-aware filter. Any content inside a <pre> ... </pre> block will also have its whitespace transformed.
Usage:
From java:
TemplateModelRoot root = new SimpleHash(); root.put( "compressLines", freemarker.ext.misc.CompressLines.getInstance() ); ...
From your FM-Classic template:
The following is compressed: <transform compressLines> <p>This page consists of multiple lines.</p> <p>For every line on the page, all trailing whitespace is removed.</p> <p>Any blank lines are reduced to a single blank line.</p> </transform> ...
Note:
CompressLines
is a singleton instance. Use the
getInstance()
method to retrieve instances of this model.
LegacyCompress
,
CompressWhitespace
,
Serialized FormMethod Summary | |
---|---|
static CompressLines |
getInstance()
Retrieve a singleton instance of this class. |
boolean |
isEmpty()
Is the object empty? |
void |
transform(java.io.Reader source,
java.io.PrintWriter output)
Compresses lines within the marked portion of a FM-Classic template. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static CompressLines getInstance()
CompressLines
classpublic boolean isEmpty() throws TemplateModelException
isEmpty
in interface TemplateModel
false
, to indicate non-empty transformation
TemplateModelException
public void transform(java.io.Reader source, java.io.PrintWriter output) throws java.io.IOException, TemplateModelException
transform
in interface TemplateTransformModel
source
- the input to be transformedoutput
- the destination of the transformation
java.io.IOException
TemplateModelException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |