StringTemplate
While reading Spring AI in Action, I discovered StringTemplate.
StringTemplate is a Java template engine for generating source code, web pages, emails, or any other formatted text output. StringTemplate is particularly good at code generators, multiple site skins, and internationalization / localization. StringTemplate also powers ANTLR.
I am thinking of adding support for StringTemplate in Micronaut Views.
String template = """
You are a helpful assistant, answering questions about tabletop games.
If you don't know anything about the game or don't know the answer,
say "I don't know".
The game is {game}.
The question is: {question}.""";
String prompt = new ST(template, '{', '}')
.add("game", question.gameTitle())
.add("question", question.question())
.render();