StringTemplate Standalone Tool (STST) is a command line utility for processing templates written in the StringTemplate template language. It uses JSON format for the data the template uses. JSON is easy to learn. If you know JavaScript then you already know it.
The STST command takes the name of a template and the name of a file containing JSON format data, makes
the JSON data available to the template as attributes and processes the template with the data to produce
output text. The JSON data must have an object as its root.
Create a JSON file called data.js with this content:
{ "audience": "World" } |
Create a StringTemplate file called first.st with this content:
Hello $audience$! |
From a command prompt in the same folder as the above two files type
> stst first data.js |
The output is
Hello World! |
It also works with group files and can use the angle bracket lexer. For command usage type: stst -h
The motivation for this tool was first described in On Learning StringTemplate.
This is the very first release of this program. It is version 0.1 Feedback is welcome. The license is BSD just like StringTemplate. Source is included. Use at your own risk. See license (in the zip file) for details.
Download the stst zip file from the file sharing area or here
Save the zip file and extract it to a directory of your choosing. In the top directory there is a README.txt file. It will have instructions much like the following.