Skip to main content

Blog Archive for aberrant during June 2010

Parts 1, 2 and 3 introduced StringTemplate through the use of simple SQL, HTML and plain text examples. This article switches gears and attempts to use StringTemplate to generate a more complicated text output: Java source code. In “Effective Java: Second Edition” (go read it, no really go read it) Mr. Block puts forth the idea of using a “Builder” class...
In Part 1 and Part 2 we dealt with simple data types who's string representation is well known. Complex data types may not have a string representation that meets the needs of a particular template. // Example 1: Some objects don't have a useful toString()Object objectParamater = new Object();StringTemplate template = new StringTemplate("Hello $param$ !");...
This Article deals with StringTemplate. If you've never heard of StringTemplate or a “template engine” you might want to read either Part 1 or the official StringTemplate documentation. Template Group Files: In the first article we used a template file (.st file) to hold our template definition. In those examples we had defined a single template that spanned the entire...