Home | News | Wiki | About StringTemplate | Feedback | Support | Bugs


Latest version is 3.2.
Download now! »

Download
» Home
» Download
» News
»Using StringTemplate
» Documentation
» Wiki
» Articles
» File Sharing
» Code API
» Tech Support
»About StringTemplate
» What is it?
» Showcase
» Testimonials
» Software License
» Changes
»Feedback
»Credits
»Contact


Support StringTemplate, ANTLR Project by making a donation! Terence often pays for things like the antlr.org server, conference travel, and this site design (that alone cost US$1000). Buy him a beer and pizza remotely ;)

Search



Article List

Add Article

Highlights

[DRAFT] A Functional Language For Generating Structured Text
Terence Parr Thu May 11, 2006 10:22
Abstract : This paper describes ST (StringTemplate), a domain-specific...

Enforcing Strict Model-View Separation in Template Engines
Terence Parr Thu May 20, 2004 13:00
A paper describing what exactly model-view separation means and characterizing...

Language Translation Using ANTLR and StringTemplate
Terence Parr Sat Feb 5, 2005 10:00
This article demonstrates how to translate a very simple C dialect, which...


RSS Feed


The Importance of Model-View Separation (a conversation with Terence Parr)
Bill Venners Fri Mar 21, 2008 08:56
In this interview with Artima, Terence Parr, creator of the StringTemplate template engine as well as the ANTLR parser generator, talks about the importance of separating business logic and presentation.

Script injection and StringTemplate
John Snyders Fri Feb 15, 2008 19:13
Some thoughts on rendering in StringTemplate. What can be done to protect against script injection in HTML without the template author needing to be aware of escaping rules?

Setting up ANTLR/ST for use with Matlab
L & D Engineering LLC Sun Dec 2, 2007 11:11


Refactoring your Templates
Sander Hahn Sat Oct 13, 2007 08:55
Chronicles Sander's use of ST.

Thoughts on StringTemplate
John Snyders Wed Jun 27, 2007 17:59
Second in a series of articles on ideas for the future of StringTemplate. Part 2 is about programming-in-the-large.

Required Reading: Enforcing Strict Model-View Separation in Template Engines
David Rupp Wed Jun 6, 2007 16:01
Blog entry discussing Enforcing Strict Model-View Separation in Template Engines.

Chinese version: Enforcing Strict Model-View-Separation in Template Engines
Translated by Richie Liu Tue Jun 5, 2007 11:39
I translated the paper into Chinese and post it there, is to bring it to Chinese programmers, and make it more readable to us.

On Learning StringTemplate
John Snyders Thu Apr 26, 2007 10:46
I have been thinking lately about the learnability (the ease with which something can be learned) of StringTemplate. StringTemplate needs is a literal representation for data that can be used as input and a stand alone program to read the data and templates to produce the output text. I created a command line tool called StringTemplate Standalone Tool (STST). It takes as input the name of a file containing data in JSON format, the name of a template and optionally the name of a group as well as various options.

Web app investigation part 2 - StringTemplate
John Snyders Tue Mar 27, 2007 15:58
This post will describe my experience with StringTemplate. I also give some informal performance numbers.

Grokking StringTemplate
Ian Rae Tue Feb 13, 2007 14:57
The blog has conclusions after a couple of days of playing with StringTemplate in Java.

John Snyders' blog entry on ST
John Snyders Mon Dec 11, 2006 09:43
Talks about using ST in a simple website, comparing to hand-coded servlet and JSF. ST's speed is in between those two.

Terence Parr on Strict Model-View Separation in Templates
Terence Parr Wed Oct 18, 2006 10:39
An interview I did for Artima.com :)

Intelligent Web Site Page Generation
Terence Parr Fri Jul 7, 2006 14:30
Discussing factoring code for building dynamic web sites and other issues related to page design.

Using StringTemplate in Page classes
Terence Parr Fri Jul 7, 2006 14:29
How to integrate ST into some servlets; look near the bottom of the page.

The Role of Template Engines in Code Generation
Terence Parr Fri Jul 7, 2006 09:36
A multimedia version of my presentation at Microsoft Research in July of 2004.

[DRAFT] A Functional Language For Generating Structured Text
Terence Parr Thu May 11, 2006 10:22
Abstract: This paper describes ST (StringTemplate), a domain-specific functional language for generating structured text from internal data structures that has the flavor of an output grammar. ST's feature set is driven by solving real problems encountered in complicated systems such as ANTLR version 3's retargetable code generator. Features include template group inheritance, template polymorphism, lazy evaluation, recursion, output auto-indentation, and the new notions of group interfaces and template regions. Experience shows that ST is easy to learn and satisfying to use.

ST's primary contribution is the clear identification and implementation of a tightly-bracketed solution to the problem of rendering data structures to text, as dictated by the nature of generation and the critical goal of strictly separating the generation logic from the output templates. First, the very nature of code generation suggests the use of a generational grammar. Next, enforcing separation of the generation logic from the output templates restricts the template language syntactically and semantically in such way that templates are easily shown to be equivalent to a grammar. Finally, the rules of separation, such as side-effect free expressions, coincide with the fundamentals of pure, functional programming.

The Internationalization and Localization of Web Applications
Terence Parr Tue Feb 21, 2006 11:49
A template engine that strictly enforces model-view separation has been shown to be at least as expressive as a context free grammar allowing the engine to, for example, easily generate any file describable by an XML DTD. When faced with supporting internationalized web applications, however, template engine designers have backed off from enforcing strict separation, allowing unrestricted embedded code segments because it was unclear how localization could otherwise occur. The consequence, unfortunately, is that each reference to a localized data value, such as a date or monetary value, replicates essentially the same snippet of code thousands of times across hundreds of templates for a large site. The potential for cut-and-paste induced bugs and the duplication of code proves a maintenance nightmare. Moreover, page designers are ill-equipped to deal with code fragments. But the difficult question remains: How can localization be done without allowing unrestricted embedded code segments that open the door to model-view entanglement? The answer is simply to automate the localization of data values, thus, avoiding code duplication, making it easier on the developer and designer, and reducing opportunities for the introduction of bugs--all-the-while maintaining the sanctity of strict model-view separation. This paper describes how the StringTemplate template engine strictly enforces model-view separation while handily supporting internationalized web application architectures. Demonstrations of page text localization, locale-specific site designs, and automatic data localization are provided.

Example: Internationalization and localization with StringTemplate
Terence Parr Fri Jan 27, 2006 19:20
StringTemplate provides a simple and effective method for localizing web pages. This article not only illustrates how to make a pages change text

Slides from BEA Presentation
Terence Parr Fri Apr 1, 2005 17:37
Jean Bovet and I went to BEA to show off StringTemplate, ANTLR, and ANTLRWorks.

Language Translation Using ANTLR and StringTemplate
Terence Parr Sat Feb 5, 2005 10:00
This article demonstrates how to translate a very simple C dialect, which I will call "C-" in honor of the grades I received in college, to three different languages, again using a single model and controller with multiple views. The targets are Java, Python, and bytecodes similar to the Jasmin Java bytecode assembler format. Merely swapping in a new template file generates completely different output without even recompiling the translator! This limited dialect of C is not particularly functional, but is complicated enough to be interesting from a translation point of view.

The Evolution of the StringTemplate Engine
Terence Parr Wed Dec 15, 2004 13:00
Slides from my presentation at UC Berkeley's Harmonia group

Generating Java and XML Using StringTemplate
Terence Parr Wed Aug 18, 2004 10:00
This small article demonstrates how a Java program may dump out its own field/method interface as Java text using reflection and then generate the interface in XML--all without changing the generation logic.

The Role Of Template Engines in Code Generation
Terence Parr Sun Jul 25, 2004 10:00
Slides from my presentation at Microsoft Research.

Enforcing Strict Model-View Separation in Template Engines
Terence Parr Thu May 20, 2004 13:00
A paper describing what exactly model-view separation means and characterizing the generational power of a template engine that enforces separation; academically-oriented but it's very readable. It was nominated for best paper at the selective WWW2004 conference.

Slides from WWW2004 Conference
Terence Parr Thu May 20, 2004 12:00
Slides from my presentation of the Enforcing Model-View Separation in Template Engines paper.