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 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.


Quick Start

$ cd /usr/local/lib
$ sudo curl -O
$ export CLASSPATH=".:/usr/local/lib/ST-4.3.4.jar:$CLASSPATH"
$ cd /usr/local/lib
$ wget
$ export CLASSPATH=".:/usr/local/lib/ST-4.3.4.jar:$CLASSPATH"
import org.stringtemplate.v4.*;
ST hello = new ST("Hello, <name>!");
hello.add("name", "World");
String output = hello.render();
Hello, World!

Latest News


The decision to use Antlr and StringTemplate for Oracles next generation Migration and SQL Developer features was easy due to the fantastic support on the forums, extensive documentation and great tools. In particular, the ability to parse trees and define target languages using StringTemplate, provided the end to end language translation technology we required. Dermot O'Neill, Oracle Senior Software Engineer
StringTemplate is one of the coolest tools ever
I find these set of tools to be one of my core tools when developing complex apps. This time, I have been using StringTemplate to develop another code generator for PostgreSQL and .NET. Terence you are great. Gevik Babakhani
StringTemplate is fantastic!
We use StringTemplate as our presentation engine for our rapid code development tool Hannibal. We chose StringTemplate over other templating engines for its ease of use, its versatility, and it disciplined approach to templating. We use it to generate code in multiple languages as well as to create XHTML and HTML code for presentation purposes. Bediako George