What is StringTemplate and how does it work?
masterStringTemplate (ST) is a text generation engine designed to enforce strict separation between the model (data) and the view (templates). It works by taking a template—a document containing text and "holes" called attribute expressions—and "rendering" it with specific values.
By default, attribute expressions are enclosed in angle brackets <attribute-expression>, though these delimiters can be customized. StringTemplate treats everything outside these expressions as literal text.
In the MVC (Model-View-Controller) pattern:
- Templates represent the View.
- Program objects (strings, integers, etc.) represent the Model.
- The code that pulls from the model and injects attributes into the template represents the Controller.