|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object freemarker.ext.misc.RemoveBlankLines
public final class RemoveBlankLines
A transform model that removes all blank lines. In addition, trailing whitespace is also deleted. Thus, for a line containing only whitespace, the entire line will be removed. Finally, the last line will not have a linefeed at the end of it
Newlines are detected by the BufferedReader.readLine()
method,
and are rewritten using the platform default (using the
System.getProperty()
method).
Usage:
From java:
TemplateModelRoot root = new SimpleHash(); root.put( "removeBlankLines", freemarker.ext.misc.RemoveBlankLines.getInstance() ); ...
From your FM-Classic template:
The following is has empty lines removed: <transform removeBlankLines> <ul> <foreach item in listItems> <li>${item}</li> <foreach> </ul> </transform> ...
Note:
RemoveBlankLines
is a singleton instance. Use the
getInstance()
method to retrieve instances of this model.
Method Summary | |
---|---|
static RemoveBlankLines |
getInstance()
Retrieve a singleton instance of this class. |
boolean |
isEmpty()
Is the object empty? |
void |
transform(java.io.Reader source,
java.io.Writer output)
Strips all blank lines from the source. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static RemoveBlankLines getInstance()
RemoveBlankLines
classpublic boolean isEmpty() throws TemplateModelException
isEmpty
in interface TemplateModel
false
to indicate that this model is non-empty
TemplateModelException
public void transform(java.io.Reader source, java.io.Writer output) throws java.io.IOException, TemplateModelException
transform
in interface TemplateTransformModel2
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 |