Output Filters

Skip to end of metadata
Go to start of metadata

Output Filters

Version 2.0 introduced the notion of an StringTemplateWriter/IStringTemplateWriter. All text rendered from a template goes through one of these writers before being placed in the output buffer. Terence added this primarily for auto-indentation for code generation, but it also could be used to remove whitespace (as a compression) from HTML output. Most recently, in 2.3, Terence updated the interface to support automatic line wrapping. If you don't care about indentation, you can simply subclass AutoIndentWriter and override write()/Write():

Java
C#
Python

Here is a "pass through" writer that is already defined:

Java
C#
Python

Use it like this:

Java
C#
Python

Instead of using nameST.toString(), which calls write with a string write and returns its value, manually invoke write with your writer.

If you want to always use a particular output filter, then use

Java
C#
Python

The StringTemplate.toString() method is sensitive to the group's writer class.

Labels:
None
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.