What is StringTemplate?
StringTemplate is a java template engine (with
ports for C#, Objective-C, JavaScript, Scala) for generating source code, web
pages, emails, or any other formatted text output. StringTemplate is
particularly good at code generators, multiple site skins, and
internationalization / localization. StringTemplate
also powers ANTLR.
Terence Parr is the maniac behind ANTLR and has been
working on language tools since 1989. He is a professor of computer
science at the
University of San Francisco.
Samples
Quick Start
OS X
$ cd /usr/local/lib
$ sudo curl -O https://www.stringtemplate.org/download/ST-4.3.4.jar
$ export CLASSPATH=".:/usr/local/lib/ST-4.3.4.jar:$CLASSPATH"
Linux
$ cd /usr/local/lib
$ wget https://stringtemplate.org/download/ST-4.3.4.jar
$ export CLASSPATH=".:/usr/local/lib/ST-4.3.4.jar:$CLASSPATH"
Windows
import org.stringtemplate.v4.*;
...
ST hello = new ST("Hello, <name>!");
hello.add("name", "World");
String output = hello.render();
System.out.println(output);
Hello, World!