Skip to Main Content
Language Implementation Patterns
book

Language Implementation Patterns

by Terence Parr
December 2009
Intermediate to advanced content levelIntermediate to advanced
380 pages
9h 2m
English
Pragmatic Bookshelf
Content preview from Language Implementation Patterns

Getting Started with StringTemplate

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

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Implementation Patterns

Implementation Patterns

Kent Beck

Publisher Resources

ISBN: 9781680500097Errata Page