December 2009
Intermediate to advanced
380 pages
9h 2m
English
ST templates are chunks of text and expressions enclosed in angle brackets: <expression>. (You can also tell it to use $expression$.) ST ignores everything outside the expressions, treating it as just text to spit out. ST is a lightweight library (not a tool or server) with two key classes: StringTemplate and StringTemplateGroup. We can create StringTemplate objects using a string literal in code or load them from a template group file using StringTemplateGroup.
The basic idea behind constructing output is that we create a template and inject it with attributes (any Java object). The expressions within a template feed on these attributes to compute text values. We create nested template hierarchies by injecting ...