StringTemplate

What is StringTemplate?

StringTemplate is a java template engine (with ports for C#, JavaScript, Python) 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.

Samples

Quick Start

OS X
$ cd /usr/local/lib
$ sudo curl -O http://www.stringtemplate.org/download/ST-4.0.8.jar
$ export CLASSPATH=".:/usr/local/lib/ST-4.0.8.jar:$CLASSPATH"
Linux
$ cd /usr/local/lib
$ wget http://stringtemplate.org/download/ST-4.0.8.jar
$ export CLASSPATH=".:/usr/local/lib/ST-4.0.8.jar:$CLASSPATH"
Windows
sample template
		
java code that uses it
		
output
		
Linux
Mac

Latest News

Testimonials

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