3.2.1 Release Notes

StringTemplate 3.2.1 Release Notes

Brought to you by that maniac that brings you the ANTLR parser generator!

Terence Parr
University of San Francisco
parrt at cs dot usfca dot edu
Copyright 2003-2009
http://www.stringtemplate.org (StringTemplate released under BSD License)

Version 3.2.1 – September 22, 2009

3.2.1 fixes a number of bugs (see the Bug list)


  • Added line break operator <backslashbackslash> (stupid wiki won't let me put two \ in a row). It consumes remaining whitespace on that line, the first and then any whitespace. Added a number of unit tests. example:
      "foo <\\>
    emits "foo bar". All of the whitespace after the line break operator gets thrown away like a comment.

Bug fixes

  • If default arg is a template with single expression wrapped in parens, x={<(...)>}, then eval to string rather than setting x to the template for later eval. Useful in rare cases where the expression can change value when you read it, such as accessing time value or random number generator object.
  • IF with false condition results in missing not empty value. So,
    <names:{n | <if(n.cool)><n><endif>}; separator=",">
    doesn't emit a separator for non-cool names. See
    WARNING: You now pay a penalty now for a separator if the iterated value is nullable. Nullable if iterable or a template with nothing buf IF statements. If nullable, ST writes each element to a temp buffer before emitting. Expensive.
  • IF conditionals and list elements couldn't use template application. Can do $if(names:{$it$})$Fail!$endif$ and $[names:{$it$!},phones]$ and $[names, ["foo","bar"]:{$it$!},phones]$. Can't use IF inside of a [...] because those are expressions not statements.
  • Made template output sensitive to the anchor of any enclosing template
    instances. ST used to ignore anchor unless you had a wrap and now it
    looks at anchor like an indent; uses widest. ST used to give this:
    	{ a, 
    	{ 1,
    	3 }
    	, b }
    for these templates where the first was stuck into second
    	<\n>{ <stuff; anchor, separator=",\n"> }<\n>
            { <values; anchor, separator=", "> }
    but now gives:
    	{ a, 
    	  { 1,
    	    3 }
    	  , b };
    see testSubtemplatesAnchorToo()