I am getting started with StringTemplate 4 and I am trying to create a template from a simple string stored in a database. I use something like this:
STGroup
The documentation for CompiledST states tokens is only for debug. Not sure what that means.
ST template = new ST("Hello , how are you? Using expression in condition works, and repeating is not a problem.");
Set expressions = new HashSet();
TokenStream tokens = template.impl.tokens;
for (int i = 0; i < tokens.range(); i++) {
Token token = tokens.get(i);
if (token.getType() == STLexer.ID) {
expressions.add(token.getText());
}
}
Gives you the Strings username and condition.