StringTemplate 2.1 Release Notes
StringTemplate 2.1 Release Notes
Brought to you by that maniac that brings you
ANTLR!
Terence Parr
University of San Francisco
parrt@cs.usfca.edu
Copyright 2003-2005
http://www.stringtemplate.org
(StringTemplate released under BSD License)
Version 2.1, January 22, 2005
2.1 is a bug fix and small feature enhancement release. 2.1 should be
a drop-in replacement for those using StringTemplate for websites.
Some newline handling differences exist, particularly for
those using the group file format. (If you are generating code not
html, you will note some newlines are missing that used to be there;
see the use of <\n> below).
Enhancements
- Added
/** Specify a StringTemplateWriter implementing class to use for
* filtering output
*/
public void setStringTemplateWriter(Class c) {
userSpecifiedWriter = c;
}
and made StringTemplate.toString() sensitive to it.
- added support for nonlocal file encodings; added property
fileCharEncoding. The template loading routines are now sensitive to
this property. Defaults to the file.encoding system property.
- updated testing harness to be same as ANTLR 3.0's which is more
sophisticated.
- addressed whitespace at begin/end of template .st file issue.
Decided to let it continue to strip all front/back whitespace and then
make you add it directly. This is a simple rule and can be made to do
what you want. It is consistent with the strip newline before >>
rule too.
- newlines ignored before <else> and <endif>. Rule is: kill a single
newline after <if>, <<, <else>, and <endif> (but for <endif> only if
it's on a line by itself) . Kill newlines before <else> and <endif>
and >>. the newline immediately preceding >> in a template group file
is tossed out just like the newline right after the <<
- added <n>, <r>, <t>, < > (space char)
- added $!...!$ and <!...!> comments (version 2.1b3)
- allow HashMap, Hashtable precisely but not Map in attribute.property lookup
- Attribute attributes$ is a text string when lint mode is on that
recursively dumps out types, properties, etc... (no values)
- Templates track their embedded instances; can ask for embedded
- added isXXX accessor properties so x.special invokes x.getSpecial
then x.isSpecial if not successful.
- Empty output for a single attribute expression one a line by itself gets no newline (i.e., you don't get a blank line).
Bug Fixes
- bug in st.attribute...if no attributes table, got null ptr exception
- fixed n refs in TestStringTemplate unit tests to be portable newline reference.
- STG.templateIsDefinedInThisGroup -> isDefinedInThisGroup
- added isDefined(name) that checks whole hierarchy
- trap all antlr generated errors now and send to listener.
- Made null indirect template generate nothing; used to generate
null-ptr exception.