freemarker.template.utility

Class NormalizeNewlines

Implemented Interfaces:
TemplateModel, TemplateTransformModel

public class NormalizeNewlines
extends java.lang.Object
implements TemplateTransformModel

Transformer that supports FreeMarker legacy behavior: all newlines appearing within the transformed area will be transformed into the platform's default newline. Unlike the old behavior, however, newlines generated by the data model are also converted. Legacy behavior was to leave newlines in the data model unaltered.

Usage:
From java:

 SimpleHash root = new SimpleHash();

 root.put( "normalizeNewlines", new freemarker.template.utility.NormalizeNewlines() );

 ...
 

From your FreeMarker template:

 <transform normalizeNewlines>
   <html>
   <head>
   ...
   <p>This template has all newlines normalized to the current platform's
   default.</p>
   ...
   </body>
   </html>
 </transform>
 
Version:
$Id: NormalizeNewlines.java,v 1.29 2003/04/11 20:57:32 revusky Exp $

Fields inherited from interface freemarker.template.TemplateModel

NOTHING

Method Summary

Writer
getWriter(Writer out, Map args)
void
transform(Reader in, Writer out)
Performs newline normalization on FreeMarker output.

Method Details

getWriter

public Writer getWriter(Writer out,
                        Map args)
Specified by:
getWriter in interface TemplateTransformModel

transform

public void transform(Reader in,
                      Writer out)
            throws IOException
Performs newline normalization on FreeMarker output.
Parameters:
in - the input to be transformed
out - the destination of the transformation