I just found this myself. The template in the question is correct. The only thing I need to do is register the inline StringRenderer before rendering the template:
STGroup group = new STGroupFile("my_template.stg");
group.registerRenderer(String.class, new StringRenderer());
source
share